-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common): ajout du database service, ajout d'un endpoint de version
- Loading branch information
Showing
9 changed files
with
652 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { VersionController } from './controllers/version.controller'; | ||
import DatabaseService from './services/database.service'; | ||
|
||
@Module({ | ||
providers: [DatabaseService], | ||
exports: [DatabaseService], | ||
controllers: [VersionController], | ||
}) | ||
export class CommonModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
|
||
@Controller() | ||
export class VersionController { | ||
//@PublicEndpoint() | ||
@Get('version') | ||
async getVersion() { | ||
return { | ||
commit: process.env.GIT_COMMIT_SHORT_SHA, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { drizzle, PostgresJsDatabase } from 'drizzle-orm/postgres-js'; | ||
import * as postgres from 'postgres'; | ||
|
||
@Injectable() | ||
export default class DatabaseService { | ||
public readonly db: PostgresJsDatabase; | ||
|
||
constructor() { | ||
if (!process.env.DATABASE_URL) { | ||
process.env.DATABASE_URL = | ||
'postgresql://postgres:postgres@localhost:54322/postgres'; | ||
} | ||
console.log(`Initializing database service`); | ||
const client = postgres(process.env.DATABASE_URL!); | ||
this.db = drizzle(client); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.