-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
28 lines (23 loc) · 804 Bytes
/
server.ts
File metadata and controls
28 lines (23 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Application } from "https://deno.land/x/oak@14.2.0/application.ts";
import mongoose from "npm:mongoose@^6.7";
import { load } from "https://deno.land/std@0.224.0/dotenv/mod.ts";
import emojiRouter from './routers/routers.ts';
const app = new Application();
const env = await load();
const DB = env["_DB"];
console.log(DB)
app.use( async (ctx, next) => {
ctx.response.headers.set('Access-Control-Allow-Origin', '*');
ctx.response.headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
ctx.response.headers.set('Access-Control-Allow-Headers', 'Content-Type');
await next()
})
app.use(emojiRouter.routes());
app.use(emojiRouter.allowedMethods())
try{
await mongoose.connect(DB);
await app.listen( {port : 3000} )
}
catch (err) {
console.log(err);
}