setup application, server, and configs
This commit is contained in:
20
src/configs/_env.ts
Normal file
20
src/configs/_env.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import z from "zod";
|
||||
|
||||
export const _env = z
|
||||
.object({
|
||||
SERVER_HOST: z.string("Must be string."),
|
||||
SERVER_PORT: z.coerce
|
||||
.number("Must be number.")
|
||||
.int("Must be integer.")
|
||||
.min(0, "Min 0."),
|
||||
|
||||
DATABASE_HOST: z.string("Must be string.").nonempty("Must not empty."),
|
||||
DATABASE_PORT: z.coerce
|
||||
.number("Must be number.")
|
||||
.int("Must be integer.")
|
||||
.min(0, "Min 0."),
|
||||
DATABASE_USERNAME: z.string("Must be string.").nonempty("Must not empty."),
|
||||
DATABASE_PASSWORD: z.string("Must be string.").nonempty("Must not empty."),
|
||||
DATABASE_NAME: z.string("Must be string.").nonempty("Must not empty."),
|
||||
})
|
||||
.parse(Bun.env);
|
||||
9
src/configs/database.config.ts
Normal file
9
src/configs/database.config.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { _env } from "@/configs/_env";
|
||||
|
||||
export const databaseConfig = {
|
||||
host: _env.DATABASE_HOST,
|
||||
port: _env.DATABASE_PORT,
|
||||
username: _env.DATABASE_USERNAME,
|
||||
password: _env.DATABASE_PASSWORD,
|
||||
name: _env.DATABASE_NAME,
|
||||
} as const;
|
||||
6
src/configs/server.config.ts
Normal file
6
src/configs/server.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { _env } from "@/configs/_env";
|
||||
|
||||
export const serverConfig = {
|
||||
host: _env.SERVER_HOST,
|
||||
port: _env.SERVER_PORT,
|
||||
} as const;
|
||||
Reference in New Issue
Block a user