feat: bootstrap the basic app structure

This commit is contained in:
sct
2020-08-16 14:39:37 +00:00
parent 2519ac86f7
commit 89a6017c7f
16 changed files with 3511 additions and 297 deletions

31
server/index.ts Normal file
View File

@@ -0,0 +1,31 @@
import express from 'express';
import next from 'next';
import { createConnection } from 'typeorm';
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
createConnection();
app
.prepare()
.then(() => {
const server = express();
server.get('/api', (req, res) => {
res.json({ worked: true });
});
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);
});