Compare commits
1 Commits
392534a6ac
...
fdb661f32b
| Author | SHA1 | Date | |
|---|---|---|---|
| fdb661f32b |
26
.env.example
26
.env.example
@@ -1,20 +1,20 @@
|
|||||||
# Server
|
# Server
|
||||||
PORT=7002
|
FABRIC_BACKEND_GUILD_PORT=7002
|
||||||
|
|
||||||
# MySQL
|
# MySQL
|
||||||
DB_HOST=mysql-guild
|
FABRIC_BACKEND_GUILD_DB_HOST=mysql-guild
|
||||||
DB_PORT=3306
|
FABRIC_BACKEND_GUILD_DB_PORT=3306
|
||||||
DB_USER=fabric
|
FABRIC_BACKEND_GUILD_DB_USER=fabric
|
||||||
DB_PASSWORD=fabric
|
FABRIC_BACKEND_GUILD_DB_PASSWORD=fabric
|
||||||
DB_NAME=fabric_guild
|
FABRIC_BACKEND_GUILD_DB_NAME=fabric_guild
|
||||||
DB_SYNC=true
|
FABRIC_BACKEND_GUILD_DB_SYNC=true
|
||||||
DB_LOGGING=false
|
FABRIC_BACKEND_GUILD_DB_LOGGING=false
|
||||||
|
|
||||||
# Guild identity
|
# Guild identity
|
||||||
GUILD_NODE_ID=guild-node-1
|
FABRIC_BACKEND_GUILD_NODE_ID=guild-node-1
|
||||||
GUILD_NODE_NAME=Guild Node 1
|
FABRIC_BACKEND_GUILD_NODE_NAME=Guild Node 1
|
||||||
GUILD_PUBLIC_ENDPOINT=http://localhost:7002
|
FABRIC_BACKEND_GUILD_PUBLIC_ENDPOINT=http://localhost:7002
|
||||||
|
|
||||||
# Center handshake
|
# Center handshake
|
||||||
CENTER_BASE_URL=http://backend-center:7001
|
FABRIC_BACKEND_GUILD_CENTER_BASE_URL=http://backend-center:7001
|
||||||
CENTER_API_KEY=
|
FABRIC_BACKEND_GUILD_CENTER_API_KEY=
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ Guild Node service for Fabric.
|
|||||||
- Seq allocator and range query endpoints
|
- Seq allocator and range query endpoints
|
||||||
|
|
||||||
## Required env (startup hard checks)
|
## Required env (startup hard checks)
|
||||||
- `CENTER_BASE_URL`
|
- `FABRIC_BACKEND_GUILD_CENTER_BASE_URL`
|
||||||
- `CENTER_API_KEY`
|
- `FABRIC_BACKEND_GUILD_CENTER_API_KEY`
|
||||||
- `GUILD_NODE_ID`
|
- `FABRIC_BACKEND_GUILD_NODE_ID`
|
||||||
|
|
||||||
If any of the above is missing, service startup fails immediately.
|
If any of the above is missing, service startup fails immediately.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export async function introspectGuildToken(token: string): Promise<{ active: boolean; user?: { id: string; email?: string } }> {
|
export async function introspectGuildToken(token: string): Promise<{ active: boolean; user?: { id: string; email?: string } }> {
|
||||||
const centerBaseUrl = process.env.CENTER_BASE_URL;
|
const centerBaseUrl = process.env.FABRIC_BACKEND_GUILD_CENTER_BASE_URL;
|
||||||
const guildNodeId = process.env.GUILD_NODE_ID;
|
const guildNodeId = process.env.FABRIC_BACKEND_GUILD_NODE_ID;
|
||||||
const centerApiKey = process.env.CENTER_API_KEY;
|
const centerApiKey = process.env.FABRIC_BACKEND_GUILD_CENTER_API_KEY;
|
||||||
|
|
||||||
if (!centerBaseUrl || !guildNodeId || !centerApiKey) {
|
if (!centerBaseUrl || !guildNodeId || !centerApiKey) {
|
||||||
return { active: false };
|
return { active: false };
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import { IdempotencyRecord } from './entities/idempotency-record.entity';
|
|||||||
|
|
||||||
export const buildTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
export const buildTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
||||||
type: 'mysql',
|
type: 'mysql',
|
||||||
host: process.env.DB_HOST ?? 'mysql-guild',
|
host: process.env.FABRIC_BACKEND_GUILD_DB_HOST ?? 'mysql-guild',
|
||||||
port: Number(process.env.DB_PORT ?? 3306),
|
port: Number(process.env.FABRIC_BACKEND_GUILD_DB_PORT ?? 3306),
|
||||||
username: process.env.DB_USER ?? 'fabric',
|
username: process.env.FABRIC_BACKEND_GUILD_DB_USER ?? 'fabric',
|
||||||
password: process.env.DB_PASSWORD ?? 'fabric',
|
password: process.env.FABRIC_BACKEND_GUILD_DB_PASSWORD ?? 'fabric',
|
||||||
database: process.env.DB_NAME ?? 'fabric_guild',
|
database: process.env.FABRIC_BACKEND_GUILD_DB_NAME ?? 'fabric_guild',
|
||||||
entities: [
|
entities: [
|
||||||
Guild,
|
Guild,
|
||||||
Channel,
|
Channel,
|
||||||
@@ -27,6 +27,6 @@ export const buildTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
|||||||
GuildMemberRole,
|
GuildMemberRole,
|
||||||
IdempotencyRecord,
|
IdempotencyRecord,
|
||||||
],
|
],
|
||||||
synchronize: (process.env.DB_SYNC ?? 'true') === 'true',
|
synchronize: (process.env.FABRIC_BACKEND_GUILD_DB_SYNC ?? 'true') === 'true',
|
||||||
logging: (process.env.DB_LOGGING ?? 'false') === 'true',
|
logging: (process.env.FABRIC_BACKEND_GUILD_DB_LOGGING ?? 'false') === 'true',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ function requireEnv(name: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateEnv(): void {
|
function validateEnv(): void {
|
||||||
requireEnv('CENTER_BASE_URL');
|
requireEnv('FABRIC_BACKEND_GUILD_CENTER_BASE_URL');
|
||||||
requireEnv('CENTER_API_KEY');
|
requireEnv('FABRIC_BACKEND_GUILD_CENTER_API_KEY');
|
||||||
requireEnv('GUILD_NODE_ID');
|
requireEnv('FABRIC_BACKEND_GUILD_NODE_ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
@@ -43,7 +43,7 @@ async function bootstrap() {
|
|||||||
const swaggerDoc = SwaggerModule.createDocument(app, swaggerConfig);
|
const swaggerDoc = SwaggerModule.createDocument(app, swaggerConfig);
|
||||||
SwaggerModule.setup('docs', app, swaggerDoc);
|
SwaggerModule.setup('docs', app, swaggerDoc);
|
||||||
|
|
||||||
const port = process.env.PORT ? Number(process.env.PORT) : 7002;
|
const port = process.env.FABRIC_BACKEND_GUILD_PORT ? Number(process.env.FABRIC_BACKEND_GUILD_PORT) : 7002;
|
||||||
await app.listen(port);
|
await app.listen(port);
|
||||||
console.log(`Fabric.Backend.Guild listening on :${port}`);
|
console.log(`Fabric.Backend.Guild listening on :${port}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user