Move sku route to right place.
This commit is contained in:
parent
30c2cd4732
commit
6f35764a21
24
src/index.ts
24
src/index.ts
@ -1,7 +1,6 @@
|
||||
import { Signale } from 'signale';
|
||||
import ConfigHandler from './assets/configHandler';
|
||||
import express, { Request, Response } from 'express';
|
||||
import * as Eta from 'eta';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { Status, Category } from '@prisma/client';
|
||||
import * as Path from 'path';
|
||||
@ -9,7 +8,7 @@ import * as fs from 'fs';
|
||||
import routes from './routes/index.js';
|
||||
|
||||
// Get app directory.
|
||||
const __path = process.argv[1];
|
||||
export const __path = process.argv[1];
|
||||
|
||||
const logger_settings = {
|
||||
disabled: false,
|
||||
@ -43,27 +42,6 @@ export const prisma = new PrismaClient({
|
||||
|
||||
export const app = express();
|
||||
|
||||
/*
|
||||
app.get('/:id', (req, res) => {
|
||||
// retrieve data from database using id from url
|
||||
prisma.item
|
||||
.findFirst({
|
||||
where: {
|
||||
SKU: req.params.id
|
||||
}
|
||||
})
|
||||
.then((item) => {
|
||||
if (item) {
|
||||
Eta.renderFile(__path + '/src/frontend/publicInfoPage.eta.html', item).then((html) => {
|
||||
res.send(html);
|
||||
});
|
||||
} else {
|
||||
res.send('Item not found');
|
||||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
routes(app);
|
||||
|
||||
app.listen(config.global.http_port, config.global.http_listen_address, () => {
|
||||
|
22
src/routes/frontend/:id.ts
Normal file
22
src/routes/frontend/:id.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { prisma, __path } from '../../index.js';
|
||||
import * as Eta from 'eta';
|
||||
|
||||
export default (req: Request, res: Response) => {
|
||||
// retrieve data from database using id from url
|
||||
prisma.item
|
||||
.findFirst({
|
||||
where: {
|
||||
SKU: req.params.id
|
||||
}
|
||||
})
|
||||
.then((item) => {
|
||||
if (item) {
|
||||
Eta.renderFile(__path + '/src/frontend/publicInfoPage.eta.html', item).then((html) => {
|
||||
res.send(html);
|
||||
});
|
||||
} else {
|
||||
res.send('Item not found');
|
||||
}
|
||||
});
|
||||
};
|
@ -1,11 +1,13 @@
|
||||
import express from 'express';
|
||||
|
||||
// Route imports
|
||||
import skuRoute from './:id.js';
|
||||
import testRoute from './test.js';
|
||||
|
||||
// Router base is '/'
|
||||
const Router = express.Router();
|
||||
|
||||
Router.use("/test", testRoute)
|
||||
Router.use('/:id', skuRoute);
|
||||
Router.use('/test', testRoute);
|
||||
|
||||
export default Router;
|
||||
|
Loading…
Reference in New Issue
Block a user