forked from oat/in-the-database-2
init commit babey
currently basically just a boilerplate and does Absolutely Fucking Nothing
This commit is contained in:
commit
ca0852800e
8 changed files with 685 additions and 0 deletions
40
src/index.ts
Normal file
40
src/index.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import * as express from 'express';
|
||||
import * as mongoose from 'mongoose';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const config = JSON.parse(fs.readFileSync('./config/config.json', {encoding: 'utf8'}));
|
||||
|
||||
const dbClient = mongoose.connect(`${config.dbconnectionURL}/${config.dbname}`, {
|
||||
useNewUrlParser: true, // idfk what any of this does i just copied an example
|
||||
useUnifiedTopology: true,
|
||||
useFindAndModify: false,
|
||||
useCreateIndex: true
|
||||
});
|
||||
|
||||
console.log('connecting to mongodb database...');
|
||||
dbClient.then(() => {
|
||||
console.log('connected to database!');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
app.set('db', dbClient);
|
||||
app.set('config', config);
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send(`${config.name} homepage - unfinished`);
|
||||
});
|
||||
|
||||
app.get('/recent', (req, res) => {
|
||||
let query = req.query;
|
||||
});
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.status(404).send('404');
|
||||
});
|
||||
|
||||
app.listen(config.port, () => {
|
||||
console.log(`expressjs server launched on port ${config.port}, should now function properly`);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue