baraqex 1.0.67 → 1.0.68
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/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/fullstack-template/.env.example +16 -29
- package/templates/fullstack-template/README.md +9 -45
- package/templates/fullstack-template/package-lock.json +1504 -6211
- package/templates/fullstack-template/package.json +17 -47
- package/templates/fullstack-template/server.js +52 -25
- package/templates/fullstack-template/src/App.tsx +178 -1
- package/templates/fullstack-template/src/api/hello.js +19 -0
- package/templates/fullstack-template/src/api/users.js +39 -0
- package/templates/fullstack-template/src/pages/index.tsx +194 -0
- package/templates/fullstack-template/src/server.ts +2 -41
- package/templates/fullstack-template/tsconfig.json +30 -0
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { createServer
|
|
2
|
-
import helmet from 'helmet';
|
|
3
|
-
import compression from 'compression';
|
|
4
|
-
import rateLimit from 'express-rate-limit';
|
|
5
|
-
import morgan from 'morgan';
|
|
1
|
+
import { createServer } from 'baraqex/server';
|
|
6
2
|
import dotenv from 'dotenv';
|
|
7
3
|
|
|
8
4
|
// Load environment variables
|
|
@@ -34,40 +30,8 @@ const config = {
|
|
|
34
30
|
// Create server instance
|
|
35
31
|
const server = createServer(config);
|
|
36
32
|
|
|
37
|
-
// Get Express app for additional middleware
|
|
38
|
-
const app = server.getExpressApp();
|
|
39
|
-
|
|
40
|
-
// Security middleware
|
|
41
|
-
app.use(helmet({
|
|
42
|
-
contentSecurityPolicy: {
|
|
43
|
-
directives: {
|
|
44
|
-
defaultSrc: ["'self'"],
|
|
45
|
-
styleSrc: ["'self'", "'unsafe-inline'"],
|
|
46
|
-
scriptSrc: ["'self'"],
|
|
47
|
-
imgSrc: ["'self'", "data:", "https:"],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
// Compression middleware
|
|
53
|
-
app.use(compression());
|
|
54
|
-
|
|
55
|
-
// Request logging
|
|
56
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
57
|
-
app.use(morgan(process.env.NODE_ENV === 'production' ? 'combined' : 'dev'));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Rate limiting
|
|
61
|
-
const limiter = rateLimit({
|
|
62
|
-
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
63
|
-
max: process.env.NODE_ENV === 'production' ? 100 : 1000, // limit each IP to 100 requests per windowMs in production
|
|
64
|
-
message: {
|
|
65
|
-
error: 'Too many requests from this IP, please try again later.'
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
app.use('/api', limiter);
|
|
69
|
-
|
|
70
33
|
// Health check endpoint
|
|
34
|
+
const app = server.getExpressApp();
|
|
71
35
|
app.get('/health', (req, res) => {
|
|
72
36
|
res.json({
|
|
73
37
|
status: 'ok',
|
|
@@ -88,9 +52,6 @@ app.get('/api/status', (req, res) => {
|
|
|
88
52
|
});
|
|
89
53
|
});
|
|
90
54
|
|
|
91
|
-
// Enable SSR with hydration
|
|
92
|
-
server.enableSSR({ hydratable: true });
|
|
93
|
-
|
|
94
55
|
// Database connection
|
|
95
56
|
async function connectDatabase() {
|
|
96
57
|
const db = server.getDatabase();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"allowSyntheticDefaultImports": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"outDir": "./dist",
|
|
14
|
+
"rootDir": "./src",
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
|
+
"noEmit": false,
|
|
18
|
+
"jsx": "react-jsx",
|
|
19
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"]
|
|
20
|
+
},
|
|
21
|
+
"include": [
|
|
22
|
+
"src/**/*"
|
|
23
|
+
],
|
|
24
|
+
"exclude": [
|
|
25
|
+
"node_modules",
|
|
26
|
+
"dist",
|
|
27
|
+
"**/*.test.ts",
|
|
28
|
+
"**/*.spec.ts"
|
|
29
|
+
]
|
|
30
|
+
}
|