Scratch space for learning atproto app development

Add DB_PATH env var

Changed files
+10 -5
src
+1
.env.template
···
PORT="8080" # The port your server will listen on
HOST="localhost" # Hostname for the server
PUBLIC_URL="" # Set when deployed publicly, e.g. "https://mysite.com". Informs OAuth client id.
+
DB_PATH=":memory:" # The SQLite database path. Leave as ":memory:" to use a temporary in-memory database.
# CORS Settings
CORS_ORIGIN="http://localhost:*" # Allowed CORS origin, adjust as necessary
+5 -1
src/env.ts
···
dotenv.config()
export const env = cleanEnv(process.env, {
-
NODE_ENV: str({ devDefault: testOnly('test'), choices: ['development', 'production', 'test'] }),
+
NODE_ENV: str({
+
devDefault: testOnly('test'),
+
choices: ['development', 'production', 'test'],
+
}),
HOST: host({ devDefault: testOnly('localhost') }),
PORT: port({ devDefault: testOnly(3000) }),
PUBLIC_URL: str({}),
+
DB_PATH: str({ devDefault: ':memory:' }),
COOKIE_SECRET: str({ devDefault: '00000000000000000000000000000000' }),
CORS_ORIGIN: str({ devDefault: testOnly('http://localhost:3000') }),
COMMON_RATE_LIMIT_MAX_REQUESTS: num({ devDefault: testOnly(1000) }),
+4 -4
src/server.ts
···
constructor(
public app: express.Application,
public server: http.Server,
-
public ctx: AppContext,
+
public ctx: AppContext
) {}
static async create() {
-
const { NODE_ENV, HOST, PORT } = env
+
const { NODE_ENV, HOST, PORT, DB_PATH } = env
const logger = pino({ name: 'server start' })
-
const db = createDb(':memory:')
+
const db = createDb(DB_PATH)
await migrateToLatest(db)
const ingester = new Ingester(db)
const oauthClient = await createClient(db)
···
formAction: null,
},
},
-
}),
+
})
)
// Request logging