Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefelgoharyx committed Feb 15, 2023
0 parents commit 1563c80
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
8 changes: 8 additions & 0 deletions main/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tasks": {
"dev": "deno run -A --watch ./main.ts"
},
"imports": {
"atom": "https://deno.land/x/atom/mod.ts"
}
}
8 changes: 8 additions & 0 deletions main/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Atom from "@/mod.ts";
async function main() {
await Atom.bootstrap({
routesPath: "example/routes",
});
}

main();
16 changes: 16 additions & 0 deletions main/routes/(get).ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MiddlewareHandler, RequestHandler } from "@/types.ts";

const _ageMiddleware: MiddlewareHandler = (req) => {
const searchString = new URL(req.url).search;
const searchParams = new URLSearchParams(searchString);
const age = searchParams.get("age");
if (!age || +age < 18) return new Response("You are unauthorized", { status: 401 });
};

const handler: RequestHandler = (req) => {
return new Response(`Hello worlds your url is ${req.url} `);
};

export const middlewares = [];

export default handler;

0 comments on commit 1563c80

Please sign in to comment.