mirror of
https://github.com/pawelmalak/snippet-box.git
synced 2025-12-23 22:18:06 +01:00
Finished snippet controller
This commit is contained in:
@@ -2,6 +2,7 @@ import dotenv from 'dotenv';
|
||||
import express from 'express';
|
||||
import { Logger } from './utils';
|
||||
import { connectDB } from './db';
|
||||
import { errorHandler } from './middleware';
|
||||
|
||||
// Routers
|
||||
import { snippetRouter } from './routes/snippets';
|
||||
@@ -11,7 +12,7 @@ dotenv.config({ path: './src/config/.env' });
|
||||
|
||||
const app = express();
|
||||
const logger = new Logger('server');
|
||||
const PORT = process.env.PORT;
|
||||
const PORT = process.env.PORT || 5000;
|
||||
|
||||
// App config
|
||||
app.use(express.json());
|
||||
@@ -19,6 +20,9 @@ app.use(express.json());
|
||||
// Routes
|
||||
app.use('/api/snippets', snippetRouter);
|
||||
|
||||
// Error handler
|
||||
app.use(errorHandler);
|
||||
|
||||
(async () => {
|
||||
await connectDB();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user