added prefix config

This commit is contained in:
Joe Arndt 2026-02-10 11:35:18 -06:00
parent a7ec0e3cde
commit 3f258bcd33
4 changed files with 12 additions and 13 deletions

View file

@ -1,4 +1,4 @@
# common-cents-api # Common Cents API
REST API for expense tracking and budgeting. REST API for expense tracking and budgeting.
## Project setup ## Project setup
@ -14,9 +14,11 @@ Start the API:
```bash ```bash
npm run start:dev npm run start:dev
``` ```
Verify running via the [healthcheck](http://localhost:3000/common-cents/health) endpoint. Verify running via the [healthcheck](http://localhost:3000/common-cents/healthcheck) endpoint.
Default port (`3000`) can be changed by setting the `PORT=xxxx` environment variable. Default port (`3000`) can be changed by setting the `PORT=` environment variable.
Default prefix (`common-cents`) can be changed by setting the `PREFIX=` environment variable.
### Database ### Database
Supported configurations: Supported configurations:
@ -35,14 +37,11 @@ For external Postgres, configure additional environment variables. To simplify t
```text ```text
# .env # .env
# API port # API Config
PORT=3000 PORT=3000
PREFIX=common-cents
# Either 'sqlite' or 'postgres' (if not set sqlite will be used) DB_TYPE=sqlite # 'sqlite' or 'postgres'
DB_TYPE=sqlite DB_SYNC=true # Sync should be false for production
# Sync should be false for production
DB_SYNC=true
# Postgres overrides # Postgres overrides
PG_HOST=localhost PG_HOST=localhost

View file

@ -5,7 +5,7 @@ meta {
} }
get { get {
url: {{localBaseUrl}}/health url: {{localBaseUrl}}/healthcheck
body: none body: none
auth: inherit auth: inherit
} }

View file

@ -2,7 +2,7 @@ import { Controller, Get } from '@nestjs/common';
@Controller() @Controller()
export class AppController { export class AppController {
@Get('health') @Get('healthcheck')
health() { health() {
return { status: 'healthy' }; return { status: 'healthy' };
} }

View file

@ -4,7 +4,7 @@ import { NestExpressApplication } from '@nestjs/platform-express';
async function bootstrap(): Promise<void> { async function bootstrap(): Promise<void> {
const app = await NestFactory.create<NestExpressApplication>(AppModule); const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.setGlobalPrefix('common-cents'); app.setGlobalPrefix(process.env.PREFIX ?? 'common-cents');
await app.listen(process.env.PORT ?? 3000); await app.listen(process.env.PORT ?? 3000);
} }
void bootstrap(); void bootstrap();