-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Move the Foxify demo to examples directory
- Loading branch information
1 parent
6c2f50e
commit dc985da
Showing
67 changed files
with
258 additions
and
203 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"foxify": patch | ||
"@foxify/http": patch | ||
"@foxify/inject": patch | ||
"@foxify/router": patch | ||
--- | ||
|
||
Fix module imports |
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,9 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"resolveJsonModule": true, | ||
"rootDir": ".", | ||
"baseUrl": ".", | ||
"noEmit": 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
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
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"baseUrl": ".", | ||
"noEmit": 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
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"baseUrl": ".", | ||
"noEmit": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Foxify Example | ||
|
||
> TODO |
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,22 @@ | ||
{ | ||
"name": "foxify-example", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "Foxify Benchmarks", | ||
"type": "module", | ||
"scripts": { | ||
"start": "ts-node-esm src/index.ts" | ||
}, | ||
"dependencies": { | ||
"@foxify/http": "workspace:^", | ||
"@foxify/router": "workspace:^", | ||
"foxify": "workspace:^", | ||
"ejs": "^3.1.8", | ||
"morgan": "^1.10.0" | ||
}, | ||
"devDependencies": { | ||
"@types/ejs": "^3.1.1", | ||
"@types/morgan": "^1.9.3", | ||
"@types/node": "^18.11.9" | ||
} | ||
} |
File renamed without changes.
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,38 @@ | ||
import path from "node:path"; | ||
import url from "node:url"; | ||
import Foxify from "foxify"; | ||
import morgan from "morgan"; | ||
import routes from "./routes/index.js"; | ||
|
||
const ROOT_DIR = path.join(path.dirname(url.fileURLToPath(import.meta.url)), ".."); | ||
|
||
const app = (new Foxify); | ||
|
||
// Settings | ||
app | ||
.set("url", "localhost") | ||
.set("port", 3000) | ||
.set("workers", 1); | ||
|
||
// Template engine support | ||
app.engine( | ||
"ejs", | ||
path.join(ROOT_DIR, "views"), | ||
// eslint-disable-next-line no-underscore-dangle,@typescript-eslint/no-explicit-any | ||
(await import("ejs") as any).__express, | ||
); | ||
|
||
// Static serve support | ||
app.use(Foxify.static(path.join(ROOT_DIR, "public"))); | ||
|
||
// Express middleware support | ||
app.use(morgan("dev")); | ||
|
||
// Routes | ||
app.use(routes); | ||
|
||
// Log the routes | ||
console.info(app.prettyPrint()); | ||
|
||
// Start the app | ||
app.start(() => console.info(`Foxify server running at http://${ app.setting("url") }:${ app.setting("port") } (worker: ${ process.pid })`)); |
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,48 @@ | ||
import { STATUS, HttpError } from "@foxify/http"; | ||
import Router, { SchemaOptionsI } from "@foxify/router"; | ||
|
||
const router = (new Router); | ||
|
||
router.get("/", (req, res) => { | ||
res.render("index", { | ||
logo : "https://avatars1.githubusercontent.com/u/36167886?s=200&v=4", | ||
title: "Foxify", | ||
}); | ||
}); | ||
|
||
router.get("/greet", (req, res) => { | ||
res.json({ | ||
hello: "world", | ||
}); | ||
}); | ||
|
||
const schema: SchemaOptionsI = { | ||
response: { | ||
200: { | ||
type : "object", | ||
properties: { | ||
hello: { | ||
type: "string", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
router.get("/greet-fast", { | ||
schema, | ||
}, (req, res) => { | ||
res.json({ | ||
hello: "world", | ||
}); | ||
}); | ||
|
||
router.get("/404", () => { | ||
throw new HttpError("This is a demo", STATUS.NOT_FOUND); | ||
}); | ||
|
||
router.get("/error", async () => { | ||
throw new Error("Oops!"); | ||
}); | ||
|
||
export default router; |
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,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"noEmit": true | ||
} | ||
} |
File renamed without changes.
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
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,5 +1,4 @@ | ||
tests/ | ||
coverage/ | ||
demo/ | ||
tsconfig*.json | ||
*.tsbuildinfo |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.