tangled
alpha
login
or
join now
ciaran.co.za
/
cumulus
0
fork
atom
A Prediction Market on the AT Protocol
0
fork
atom
overview
issues
pulls
pipelines
refactor(core/env.ts): cleanup env
Ciaran
4 days ago
d77c0035
c84ec1bf
+9
-11
6 changed files
expand all
collapse all
unified
split
.env.example
drizzle.config.ts
src
core
constants.ts
env.ts
db
index.ts
server
index.ts
-1
.env.example
···
1
1
PORT=8080
2
2
-
BASE_URL=https://example.com
3
2
DATABASE_URL=postgresql://...
+1
-1
drizzle.config.ts
···
1
1
-
import { ENV } from '@/core/constants';
1
1
+
import { ENV } from '@/core/env';
2
2
import 'dotenv/config';
3
3
import { defineConfig } from 'drizzle-kit';
4
4
-7
src/core/constants.ts
···
1
1
-
import { z } from "zod"
2
1
3
2
export enum Lexicon {
4
3
MARKET = 'za.co.ciaran.cumulus.market',
5
4
BET = 'za.co.ciaran.cumulus.bet',
6
5
RESOLUTION = 'za.co.ciaran.cumulus.resolution',
7
6
}
8
8
-
9
9
-
export const ENV = z.object({
10
10
-
PORT: z.coerce.number(),
11
11
-
BASE_URL: z.url(),
12
12
-
DATABASE_URL: z.stringFormat("postgresql://", (val) => val.startsWith("postgresql://")),
13
13
-
}).parse(process.env);
+6
src/core/env.ts
···
1
1
+
import { z } from "zod"
2
2
+
3
3
+
export const ENV = z.object({
4
4
+
PORT: z.string(),
5
5
+
DATABASE_URL: z.stringFormat("postgresql://", (val) => val.startsWith("postgresql://")),
6
6
+
}).parse(import.meta.env);
+1
-1
src/db/index.ts
···
1
1
import { text, integer, json, pgTable, timestamp, pgEnum, index } from "drizzle-orm/pg-core";
2
2
import { relations } from "drizzle-orm";
3
3
import { drizzle } from "drizzle-orm/node-postgres";
4
4
-
import { ENV } from "@/core/constants";
4
4
+
import { ENV } from "@/core/env";
5
5
6
6
const SHARED_SCHEMA = {
7
7
uri: text().primaryKey().notNull(),
+1
-1
src/server/index.ts
···
3
3
import { swagger } from '@elysiajs/swagger'
4
4
import { cors } from '@elysiajs/cors'
5
5
import { tryFindMarket, tryFindMarketBets, tryFindMarketResolutions, tryListMarkets } from "@/core/api";
6
6
-
import { ENV } from "@/core/constants";
6
6
+
import { ENV } from "@/core/env";
7
7
8
8
export const app = new Elysia()
9
9
.use(cors())