-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f19d42
commit 307ed26
Showing
4 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
import { Router } from "../deps.ts"; | ||
import User, { LoginResult, UserCredential } from "../models/User.ts"; | ||
|
||
const AuthRouter = new Router({ | ||
prefix: "/", | ||
const AuthRouter = new Router(); | ||
|
||
AuthRouter.post("/login", async (ctx) => { | ||
const userCredentials: UserCredential = (await ctx.request.body()).value; | ||
console.log("Login"); | ||
const user: LoginResult = await User.logIn(userCredentials); | ||
console.log(user); | ||
}); | ||
|
||
AuthRouter.get("/login", async (ctx) => { | ||
ctx.response.body = "Hello world"; | ||
AuthRouter.post("/register", async (ctx) => { | ||
console.log("register"); | ||
const newUser = (await ctx.request.body()).value; | ||
console.log(newUser); | ||
const result = await User.create(newUser); | ||
if (result) { | ||
ctx.response.status = 200; | ||
ctx.response.body = { | ||
"message": "User created Succesfully", | ||
}; | ||
} | ||
}); | ||
|
||
AuthRouter.get('/logout', async(ctx) => { | ||
|
||
console.log('Log out') | ||
}) | ||
|
||
export default AuthRouter; |