-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from yracnet/v1.1.x-beta
V1.1.x beta
- Loading branch information
Showing
44 changed files
with
853 additions
and
210 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
vite-plugin-api-routes-*.tgz |
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,3 +1,4 @@ | ||
VITE_CODE: 1234 | ||
KEY_SECRET: 123466 | ||
API_TOKEN: 123466 | ||
API_TOKEN: 123466 | ||
JWT_SECRET: F69F37EB4D1BAB673F7B5A7D41E3A |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createAllowRoles, assertToken } from "../middleware/sessionToken"; | ||
|
||
export default [ | ||
assertToken, | ||
createAllowRoles(['ADMIN']), | ||
]; |
5 changes: 2 additions & 3 deletions
5
...ple/src/api/admin/user/[userId]/detail.ts → example/src/api/admin/post/[postId]/index.ts
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,7 +1,6 @@ | ||
//@ts-ignore | ||
import { createResponse } from "../../../../common/response.js"; | ||
|
||
//@ts-ignore | ||
export const GET = (req, res, next) => { | ||
createResponse("v2/user/[userId]/detail.ts", req, res, next); | ||
}; | ||
createResponse("v2/post/[postId].ts", req, res, next); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createResponse } from "../../../common/response.js"; | ||
|
||
//@ts-ignore | ||
export const GET = (req, res, next) => { | ||
createResponse("v2/post/index.ts", req, res, next); | ||
}; |
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,3 @@ | ||
//@ts-ignore | ||
export default (req, res, next) => { | ||
req.copyright = "HOC FOR AUTH REQUEST - TS"; | ||
next(); | ||
}; | ||
import { createAllowRoles } from "../../middleware/sessionToken"; | ||
|
||
//@ts-ignore | ||
export const GET = (req, res, next) => { | ||
//res.send({ ok: true }); | ||
next(); | ||
}; | ||
export default createAllowRoles(['USER']); |
This file was deleted.
Oops, something went wrong.
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,7 +1,12 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import { createResponseAsync } from "../../common/response.js"; | ||
import { createResponseAsync } from "../../common/response"; | ||
import { jwtSign } from "../../middleware/jwt"; | ||
|
||
export const POST = async (req: Request, res: Response, next: NextFunction) => { | ||
res.cookie("auth", true); | ||
return createResponseAsync("Logged in!", req, res, next); | ||
export const POST = (req: Request, res: Response, next: NextFunction) => { | ||
const token = jwtSign({ | ||
name: 'Willyams', | ||
roles: ['ADMIN', 'USER'], | ||
}); | ||
res.cookie('token', token, { httpOnly: false }); | ||
createResponseAsync("Logged in!", req, res, next); | ||
}; |
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,16 +1,9 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import { authMiddleware } from "../../common/authMiddleware.js"; | ||
import { createResponseAsync } from "../../common/response.js"; | ||
|
||
export const POST = async (req: Request, res: Response, next: NextFunction) => { | ||
["auth", "article", "user"].forEach(name => { | ||
["auth", "article", "user", "token"].forEach(name => { | ||
res.clearCookie(name); | ||
}); | ||
return createResponseAsync("Logged out!", req, res, next); | ||
}; | ||
|
||
/* Any amount of middlewares */ | ||
/* Like this the user cannot logout if he is not logged in */ | ||
export default [ | ||
authMiddleware | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//@ts-ignore | ||
import { createResponseAsync } from "../../common/response.js"; | ||
import { jwtSign } from "../../middleware/jwt"; | ||
|
||
//@ts-ignore | ||
export const POST = (req, res, next) => { | ||
const token = jwtSign({ | ||
name: 'User Site', | ||
roles: ['SITE'], | ||
}); | ||
res.cookie('token', token, { httpOnly: false }); | ||
return createResponseAsync("Changed in!", req, res, next); | ||
}; |
Oops, something went wrong.