Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d07dff
commit e28766a
Showing
6 changed files
with
45 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { ConfigModule } from '@nestjs/config' | ||
import { Config } from "./config"; | ||
import { AppController } from "./app.controller"; | ||
|
||
export const configuration = async (): Promise<Config> => { | ||
const { config } = <{ config: Config }> await import(`${__dirname}/config`); | ||
return config; | ||
}; | ||
import {Module} from '@nestjs/common'; | ||
import {ConfigModule} from '@nestjs/config'; | ||
import {config} from './config'; | ||
import {AppController} from './app.controller'; | ||
|
||
@Module({ | ||
controllers: [AppController], | ||
imports: [ | ||
ConfigModule.forRoot({ | ||
isGlobal: true, | ||
load: [configuration], | ||
load: [config], | ||
envFilePath: `.env`, | ||
}) | ||
}), | ||
], | ||
}) | ||
export class AppModule {} |
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 |
---|---|---|
@@ -1,16 +1,13 @@ | ||
export const config: { | ||
type Config = { | ||
Stripe: { | ||
publishable_key: string | ||
secret_key: string | ||
webhook_secret: string | ||
} | ||
} = { | ||
secret_key: string; | ||
webhook_secret: string; | ||
}; | ||
}; | ||
|
||
export const config = (): Config => ({ | ||
Stripe: { | ||
publishable_key: process.env.STRIPE_PUBLISHABLE_KEY || '', | ||
secret_key: process.env.STRIPE_SECRET_KEY || '', | ||
webhook_secret: process.env.STRIPE_WEBHOOK_SECRET || '', | ||
} | ||
} | ||
export type Config = typeof config; | ||
|
||
|
||
}, | ||
}); |
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 |
---|---|---|
@@ -1,16 +1,18 @@ | ||
#!/usr/bin/env -S npm run-script run | ||
|
||
import { NestFactory } from "@nestjs/core"; | ||
import { INestApplication } from "@nestjs/common"; | ||
import { AppModule } from "./app.module"; | ||
import {NestFactory} from '@nestjs/core'; | ||
import {INestApplication} from '@nestjs/common'; | ||
import {AppModule} from './app.module'; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create<INestApplication>(AppModule, { rawBody: true }); | ||
const app = await NestFactory.create<INestApplication>(AppModule, { | ||
rawBody: true, | ||
}); | ||
app.enableCors({ | ||
origin: "*", | ||
origin: '*', | ||
}); | ||
|
||
await app.listen(0); | ||
console.log(`Webhook endpoint available at ${await app.getUrl()}/webhook`); | ||
console.log(`Webhook endpoint available at ${await app.getUrl()}/webhooks`); | ||
} | ||
bootstrap(); |
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