Skip to content

Commit

Permalink
1,349th Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Feb 3, 2024
1 parent 8258e97 commit 8c7658d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"fastify-plugin": "^4.5.1"
},
"devDependencies": {
"process-envify": "^2.0.0",
"vite": "^5.0.12",
"vite-plugin-fastify": "^1.2.5",
"vite-plugin-fastify-routes": "^1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default () => {
app.register(multipart);

app.register(router);
// app.register(sleep);
app.register(sleep);

return app;
};
2 changes: 1 addition & 1 deletion api/src/plugins/sleep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import plugin from 'fastify-plugin';
export default plugin(
async (app) => {
app.addHook('onRequest', async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise((resolve) => setTimeout(resolve, 333.33));
});
},
{ name: 'sleep' },
Expand Down
2 changes: 1 addition & 1 deletion api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const server = app();

const start = async () => {
try {
await server.listen({ host: '127.0.0.1', port: 3000 });
await server.listen({ host: process.env.HOST, port: process.env.PORT });
} catch (err) {
server.log.error(err);
process.exit(1);
Expand Down
9 changes: 9 additions & 0 deletions api/src/shims.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/// <reference types="vite-plugin-fastify-routes/client" />

declare namespace NodeJS {
export interface ProcessEnv {
NODE_ENV: string;

HOST: string;
PORT: number;
}
}
9 changes: 5 additions & 4 deletions api/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { resolve } from 'path';
import { defineConfig } from 'vite';
import fastify from 'vite-plugin-fastify';
import fastifyRoutes from 'vite-plugin-fastify-routes';
import envify from 'process-envify';

export default defineConfig({
server: {
host: '127.0.0.1',
port: 3000,
},
define: envify({
HOST: process.env.HOST || '127.0.0.1',
PORT: process.env.PORT || 3000,
}),
plugins: [fastify(), fastifyRoutes()],
resolve: {
alias: {
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default defineConfig({
'@': path.resolve(__dirname, 'src'),
api: path.resolve(__dirname, 'api/src/routes'),
},
mainFields: ['module'],
},
server: {
proxy: {
Expand Down

0 comments on commit 8c7658d

Please sign in to comment.