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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| import { Application} from "https://deno.land/x/oak@v12.1.0/mod.ts";
import { send } from "https://deno.land/x/oak@v11.1.0/send.ts";
import { viewEngine, ejsEngine, oakAdapter } from "https://deno.land/x/view_engine@v10.5.1/mod.ts";
/*import {
viewEngine,
engineFactory,
adapterFactory,
} from "https://deno.land/x/view_engine/mod.ts";*/
import router from './routes.ts';
// esm.sh is used to compile stripe-node to be compatible with ES modules.
/*const ejsEngine = engineFactory.getEjsEngine();
const oakAdapter = adapterFactory.getOakAdapter();*/
const port = Deno.env.get("PORT") || 4000
/*const certFile = "./vainastar.com-2023-03-27.crt";
const keyFile = "./vainastar.com-2023-03-27.key.";*/
const app = new Application();
/*app.use(
viewEngine(oakAdapter, ejsEngine));*/
app.use(viewEngine(oakAdapter, ejsEngine));
app.use(router.routes());
app.use(router.allowedMethods());
app.use(async(ctx,next) => {
await send(ctx,ctx.request.url.pathname,{
root: `${Deno.cwd()}`
});
next();
});
//deno run --allow-net --allow-read --allow-env server.ts
console.log(`Server running on port ${port}`);
await app.listen({port, certFile: "./vainastar.com-2023-03-27.crt", keyFile:"./vainastar.com-2023-03-27.key.", secure: true}); |
Partager