You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
706 B
31 lines
706 B
import express from 'express';
|
|
import next from 'next';
|
|
import { createConnection } from 'typeorm';
|
|
import routes from './routes';
|
|
|
|
const dev = process.env.NODE_ENV !== 'production';
|
|
const app = next({ dev });
|
|
const handle = app.getRequestHandler();
|
|
|
|
createConnection();
|
|
|
|
app
|
|
.prepare()
|
|
.then(() => {
|
|
const server = express();
|
|
server.use('/api', routes);
|
|
server.get('*', (req, res) => handle(req, res));
|
|
|
|
const port = Number(process.env.PORT) || 3000;
|
|
server.listen(port, (err) => {
|
|
if (err) {
|
|
throw err;
|
|
}
|
|
console.log(`Ready to do stuff http://localhost:${port}`);
|
|
});
|
|
})
|
|
.catch((err) => {
|
|
console.error(err.stack);
|
|
process.exit(1);
|
|
});
|