initial commit

This commit is contained in:
2022-01-28 20:55:51 +02:00
commit dcaf6d8077
7 changed files with 1401 additions and 0 deletions

28
src/app.ts Normal file
View File

@@ -0,0 +1,28 @@
import express from "express";
import cors from 'cors';
import mongoose from 'mongoose';
import config from './config';
import io from 'socket.io';
const app: express.Application = express();
app.use(express.json());
app.use(cors());
app.get('/', function (request: express.Request, response: express.Response) {
response.json({ response: 'Hello World!' });
});
app.listen(config.port, async () => {
await mongoose.connect(config.mongodb || 'mongodb://localhost/typescript-express-api-template', {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
}, (err) => {
if (err) {
console.log(err.message);
console.log(err);
}
});
});

7
src/config.ts Normal file
View File

@@ -0,0 +1,7 @@
const config = {
prof: false,
port: 3333,
mongodb: 'mongodb://localhost/ts-example',
}
export default config;