-
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
Showing
34 changed files
with
1,332 additions
and
1,226 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 |
---|---|---|
@@ -1,42 +1,42 @@ | ||
{ | ||
"name": "Handlers.js Devlopment Container", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"args": { | ||
"VARIANT": "16-bullseye" | ||
} | ||
}, | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"ms-vscode.vscode-typescript-next", | ||
"oderwat.indent-rainbow", | ||
"GitHub.copilot", | ||
"redhat.vscode-yaml", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "yarn install", | ||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "node", | ||
"features": { | ||
"git": "latest", | ||
"docker-in-docker": { | ||
"version": "latest", | ||
"moby": true, | ||
"dockerDashComposeVersion": "v1" | ||
}, | ||
"rust": { | ||
"version": "latest", | ||
"profile": "minimal" | ||
} | ||
} | ||
} | ||
"name": "Handlers.js Devlopment Container", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"args": { | ||
"VARIANT": "16-bullseye" | ||
} | ||
}, | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"ms-vscode.vscode-typescript-next", | ||
"oderwat.indent-rainbow", | ||
"GitHub.copilot", | ||
"redhat.vscode-yaml", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "yarn install", | ||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "node", | ||
"features": { | ||
"git": "latest", | ||
"docker-in-docker": { | ||
"version": "latest", | ||
"moby": true, | ||
"dockerDashComposeVersion": "v1" | ||
}, | ||
"rust": { | ||
"version": "latest", | ||
"profile": "minimal" | ||
} | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"tabWidth": 4 | ||
} |
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,5 +1,5 @@ | ||
{ | ||
"compile-hero.disable-compile-files-on-did-save-code": true, | ||
"deno.enable": false, | ||
"editor.formatOnSave": true, | ||
} | ||
"editor.formatOnSave": true | ||
} |
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
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -1,77 +1,71 @@ | ||
import { | ||
rootRouter, | ||
method, | ||
handler, | ||
route, | ||
response, | ||
} from "../index"; | ||
import errorHandler from "./errorHandler"; | ||
import { rootRouter, method, handler, route, response } from '../index'; | ||
import errorHandler from './errorHandler'; | ||
|
||
const App = new rootRouter<any, any>(); | ||
|
||
App.binding( | ||
"/(.*)", | ||
new handler("ANY", [ | ||
async (request, response) => { | ||
console.log(request); | ||
return undefined; | ||
}, | ||
]) | ||
'/(.*)', | ||
new handler('ANY', [ | ||
async (request, response) => { | ||
console.log(request); | ||
return undefined; | ||
}, | ||
]), | ||
); | ||
|
||
App.binding( | ||
"/", | ||
App.create( | ||
"ANY", | ||
(): Promise<string> => | ||
new Promise(() => { | ||
console.log("Hello World!"); | ||
throw new response("Hello World!"); | ||
}) | ||
) | ||
'/', | ||
App.create( | ||
'ANY', | ||
(): Promise<string> => | ||
new Promise(() => { | ||
console.log('Hello World!'); | ||
throw new response('Hello World!'); | ||
}), | ||
), | ||
).binding( | ||
"/(.*)", | ||
App.create( | ||
"ANY", | ||
(): Promise<string> => | ||
new Promise((resolve) => { | ||
resolve("Hello World?") | ||
}) | ||
) | ||
'/(.*)', | ||
App.create( | ||
'ANY', | ||
(): Promise<string> => | ||
new Promise((resolve) => { | ||
resolve('Hello World?'); | ||
}), | ||
), | ||
); | ||
|
||
App.route("/v1/(.*)") | ||
.add( | ||
new route( | ||
["/echo", "/echo/(.*)"], | ||
[ | ||
new handler(method["GET"], [ | ||
async (requestMessage, responseMessage) => { | ||
responseMessage = responseMessage ?? new response(""); | ||
responseMessage?.headers.set("Hello", "World"); | ||
responseMessage.body = requestMessage.url.pathname; | ||
return responseMessage; | ||
}, | ||
]), | ||
new handler(method["POST"], [ | ||
async (requestMessage, responseMessage) => { | ||
responseMessage = responseMessage ?? new response(""); | ||
responseMessage.body = requestMessage.body; | ||
return responseMessage; | ||
}, | ||
]), | ||
] | ||
) | ||
) | ||
.binding( | ||
"/error", | ||
App.create(method["ANY"], async () => { | ||
throw new Error("Nothing will happen here."); | ||
}) | ||
) | ||
.useErrorResponder(errorHandler); | ||
App.route('/v1/(.*)') | ||
.add( | ||
new route( | ||
['/echo', '/echo/(.*)'], | ||
[ | ||
new handler(method['GET'], [ | ||
async (requestMessage, responseMessage) => { | ||
responseMessage = responseMessage ?? new response(''); | ||
responseMessage?.headers.set('Hello', 'World'); | ||
responseMessage.body = requestMessage.url.pathname; | ||
return responseMessage; | ||
}, | ||
]), | ||
new handler(method['POST'], [ | ||
async (requestMessage, responseMessage) => { | ||
responseMessage = responseMessage ?? new response(''); | ||
responseMessage.body = requestMessage.body; | ||
return responseMessage; | ||
}, | ||
]), | ||
], | ||
), | ||
) | ||
.binding( | ||
'/error', | ||
App.create(method['ANY'], async () => { | ||
throw new Error('Nothing will happen here.'); | ||
}), | ||
) | ||
.useErrorResponder(errorHandler); | ||
|
||
App.useMappingAdapter(); | ||
App.listen(8080); | ||
|
||
export default App; | ||
export default App; |
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,12 +1,12 @@ | ||
import { rootRouter } from "./src/router"; | ||
import { rootRouter } from './src/router'; | ||
|
||
export { handler } from "./src/handler"; | ||
export { route } from "./src/route"; | ||
export { router } from "./src/router"; | ||
export { methodENUM as method } from "./src/interface/method"; | ||
export { response } from "./src/interface/response"; | ||
export { request } from "./src/interface/request"; | ||
export * as platformAdapater from "./src/platform/export"; | ||
export { handler } from './src/handler'; | ||
export { route } from './src/route'; | ||
export { router } from './src/router'; | ||
export { methodENUM as method } from './src/interface/method'; | ||
export { response } from './src/interface/response'; | ||
export { request } from './src/interface/request'; | ||
export * as platformAdapater from './src/platform/export'; | ||
|
||
export { rootRouter }; | ||
export default rootRouter; |
Oops, something went wrong.