Livebeat is now able to send, store and show beats
This commit is contained in:
@@ -4,6 +4,7 @@ import { config as dconfig } from 'dotenv';
|
||||
import * as express from 'express';
|
||||
import * as figlet from 'figlet';
|
||||
import * as mongoose from 'mongoose';
|
||||
import * as cors from 'cors';
|
||||
import { exit } from 'process';
|
||||
import * as winston from 'winston';
|
||||
import { RabbitMQ } from './lib/rabbit';
|
||||
@@ -13,6 +14,8 @@ import { DeleteUser, GetUser, LoginUser, MW_User, PatchUser } from './endpoints/
|
||||
import { hashPassword, randomPepper, randomString } from './lib/crypto';
|
||||
import { UserType } from './models/user/user.interface';
|
||||
import { User } from './models/user/user.model';
|
||||
import { GetPhone, PostPhone } from './endpoints/phone';
|
||||
import { GetBeat } from './endpoints/beat';
|
||||
|
||||
// Load .env
|
||||
dconfig({ debug: true, encoding: 'UTF-8' });
|
||||
@@ -127,15 +130,29 @@ async function run() {
|
||||
*/
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use(cors());
|
||||
app.use(bodyParser.json({ limit: '5kb' }));
|
||||
|
||||
app.use((req, res, next) => {
|
||||
res.on('finish', () => {
|
||||
const done = Date.now();
|
||||
logger.debug(`${req.method} - ${req.url} ${JSON.stringify(req.body)} -> ${res.statusCode}`);
|
||||
});
|
||||
next();
|
||||
});
|
||||
|
||||
app.get('/', (req, res) => res.status(200).send('OK'));
|
||||
app.get('/user/', MW_User, (req, res) => GetUser(req, res));
|
||||
app.get('/user/:id', MW_User, (req, res) => GetUser(req, res));
|
||||
app.patch('/user/:id', MW_User, (req, res) => PatchUser(req, res));
|
||||
app.delete('/user/:id', MW_User, (req, res) => DeleteUser(req, res));
|
||||
|
||||
app.post('/user/login', (req, res) => LoginUser(req, res));
|
||||
|
||||
app.get('/phone/:id', (req, res) => GetPhone(req, res));
|
||||
app.post('/phone', MW_User, (req, res) => PostPhone(req, res));
|
||||
|
||||
app.get('/beat/', MW_User, (req, res) => GetBeat(req, res));
|
||||
|
||||
app.listen(config.http.port, config.http.host, () => {
|
||||
logger.info(`HTTP server is running at ${config.http.host}:${config.http.port}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user