Add database.ts

This commit is contained in:
rijkvanzanten
2020-06-16 14:30:48 -04:00
parent 47ec84fafd
commit 74dbdfd49b
2 changed files with 20 additions and 1 deletions

View File

@@ -1,12 +1,17 @@
import dotenv from 'dotenv';
dotenv.config();
import express from 'express';
import asyncHandler from 'express-async-handler';
import APIError, { errorHandler, ErrorCode } from './error';
import database from './database';
const app = express()
.get(
'/',
asyncHandler(async (req, res, next) => {
throw new APIError(ErrorCode.NOT_FOUND, 'Route `/` not found');
const records = await database.select('*').from('articles');
res.json(records);
})
)
.use(errorHandler);