@seip/blue-bird 0.7.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env_example +34 -34
- package/AGENTS.md +174 -249
- package/LICENSE +21 -21
- package/README.md +331 -367
- package/{index.js → backend/index.js} +22 -30
- package/backend/routes/api.js +57 -57
- package/core/app.js +338 -402
- package/core/auth.js +262 -256
- package/core/cache.js +174 -174
- package/core/cli/docker.js +488 -457
- package/core/cli/init.js +333 -337
- package/core/cli/route.js +42 -42
- package/core/config.js +52 -52
- package/core/database.js +263 -263
- package/core/debug.js +248 -248
- package/core/logger.js +115 -115
- package/core/middleware.js +27 -27
- package/core/router.js +144 -144
- package/core/swagger.js +40 -40
- package/core/upload.js +77 -77
- package/core/validate.js +380 -380
- package/docker/Dockerfile +16 -16
- package/docker/docker-compose.dev.yml +6 -0
- package/docker/docker-compose.mysql.yml +92 -92
- package/docker/docker-compose.none.yml +68 -68
- package/docker/docker-compose.postgres.yml +93 -93
- package/docker/nginx.conf +98 -106
- package/docker-compose.yml +92 -92
- package/frontend/about.html +103 -0
- package/frontend/images/favicon.ico +0 -0
- package/frontend/index.html +141 -0
- package/frontend/js/tailwind.js +8 -0
- package/package.json +64 -71
- package/frontend/astro.config.mjs +0 -35
- package/frontend/public/css/app.css +0 -319
- package/frontend/public/favicon.ico +0 -0
- package/frontend/src/http/api.js +0 -29
- package/frontend/src/layouts/Layout.astro +0 -20
- package/frontend/src/pages/about.astro +0 -54
- package/frontend/src/pages/index.astro +0 -110
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
import App from "@seip/blue-bird/core/app.js";
|
|
2
|
-
import routerApi from "./
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Main entry point for the Blue Bird application.
|
|
6
|
-
* Initializes the App instance with routes, configuration, and starts the server.
|
|
7
|
-
*/
|
|
8
|
-
const app = new App({
|
|
9
|
-
routes: [routerApi],
|
|
10
|
-
|
|
11
|
-
cors: [],
|
|
12
|
-
|
|
13
|
-
middlewares: [],
|
|
14
|
-
|
|
15
|
-
host: "http://localhost",
|
|
16
|
-
|
|
17
|
-
port: process.env.PORT,
|
|
18
|
-
|
|
19
|
-
logger:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
serverEntry: "./frontend/dist/server/entry.mjs",
|
|
24
|
-
client: true,
|
|
25
|
-
clientDir: "./frontend/dist/client",
|
|
26
|
-
base: "/",
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
app.run();
|
|
1
|
+
import App from "@seip/blue-bird/core/app.js";
|
|
2
|
+
import routerApi from "./routes/api.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main entry point for the Blue Bird application.
|
|
6
|
+
* Initializes the App instance with routes, configuration, and starts the server.
|
|
7
|
+
*/
|
|
8
|
+
const app = new App({
|
|
9
|
+
routes: [routerApi],
|
|
10
|
+
|
|
11
|
+
cors: [],
|
|
12
|
+
|
|
13
|
+
middlewares: [],
|
|
14
|
+
|
|
15
|
+
host: "http://localhost",
|
|
16
|
+
|
|
17
|
+
port: process.env.PORT,
|
|
18
|
+
|
|
19
|
+
logger: false,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
app.run();
|
package/backend/routes/api.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import Router from "@seip/blue-bird/core/router.js";
|
|
2
|
-
import Validator from "@seip/blue-bird/core/validate.js";
|
|
3
|
-
import Cache from "@seip/blue-bird/core/cache.js";
|
|
4
|
-
import Auth from "@seip/blue-bird/core/auth.js";
|
|
5
|
-
|
|
6
|
-
const routerApi = new Router("/api");
|
|
7
|
-
|
|
8
|
-
routerApi.get("//", (req, res) => {
|
|
9
|
-
res.json({ api: true, message: "Bluebird API", time: Date.now() });
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
routerApi.get("/users", (req, res) => {
|
|
13
|
-
const users = [
|
|
14
|
-
{
|
|
15
|
-
name: "John Doe",
|
|
16
|
-
email: "john.doe@example.com",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: "Jane Doe2",
|
|
20
|
-
email: "jane.doe2@example.com",
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
res.json(users);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const loginSchema = {
|
|
27
|
-
email: { required: true, email: true },
|
|
28
|
-
password: { required: true, min: 6 },
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const loginValidator = new Validator(loginSchema);
|
|
32
|
-
|
|
33
|
-
routerApi.post("/login", loginValidator.middleware(), (req, res) => {
|
|
34
|
-
res.json({ message: "Login successful", body: req.body });
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
routerApi.get("/cache", Cache.middleware(), async (req, res) => {
|
|
38
|
-
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
39
|
-
res.json({ message: "Cache successful" });
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
routerApi.get("/auth_generate", async (req, res) => {
|
|
43
|
-
const token = await Auth.login(res, { id: 1, name: "John Doe" }, "auth");
|
|
44
|
-
res.json({ message: "Auth successful", token });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
routerApi.get("/auth_logout", async (req, res) => {
|
|
48
|
-
await Auth.logout(res, "auth", {}, req);
|
|
49
|
-
res.json({ message: "Auth successful" });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
routerApi.get("/auth_verify", Auth.protect(), (req, res) => {
|
|
53
|
-
const userInfo = req.user;
|
|
54
|
-
res.json({ message: "Auth successful", user: userInfo });
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export default routerApi;
|
|
1
|
+
import Router from "@seip/blue-bird/core/router.js";
|
|
2
|
+
import Validator from "@seip/blue-bird/core/validate.js";
|
|
3
|
+
import Cache from "@seip/blue-bird/core/cache.js";
|
|
4
|
+
import Auth from "@seip/blue-bird/core/auth.js";
|
|
5
|
+
|
|
6
|
+
const routerApi = new Router("/api");
|
|
7
|
+
|
|
8
|
+
routerApi.get("//", (req, res) => {
|
|
9
|
+
res.json({ api: true, message: "Bluebird API", time: Date.now() });
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
routerApi.get("/users", (req, res) => {
|
|
13
|
+
const users = [
|
|
14
|
+
{
|
|
15
|
+
name: "John Doe",
|
|
16
|
+
email: "john.doe@example.com",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "Jane Doe2",
|
|
20
|
+
email: "jane.doe2@example.com",
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
res.json(users);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const loginSchema = {
|
|
27
|
+
email: { required: true, email: true },
|
|
28
|
+
password: { required: true, min: 6 },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const loginValidator = new Validator(loginSchema);
|
|
32
|
+
|
|
33
|
+
routerApi.post("/login", loginValidator.middleware(), (req, res) => {
|
|
34
|
+
res.json({ message: "Login successful", body: req.body });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
routerApi.get("/cache", Cache.middleware(), async (req, res) => {
|
|
38
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
39
|
+
res.json({ message: "Cache successful" });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
routerApi.get("/auth_generate", async (req, res) => {
|
|
43
|
+
const token = await Auth.login(res, { id: 1, name: "John Doe" }, "auth");
|
|
44
|
+
res.json({ message: "Auth successful", token });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
routerApi.get("/auth_logout", async (req, res) => {
|
|
48
|
+
await Auth.logout(res, "auth", {}, req);
|
|
49
|
+
res.json({ message: "Auth successful" });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
routerApi.get("/auth_verify", Auth.protect(), (req, res) => {
|
|
53
|
+
const userInfo = req.user;
|
|
54
|
+
res.json({ message: "Auth successful", user: userInfo });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default routerApi;
|