feat: scaffold center and guild backend NestJS skeletons

This commit is contained in:
nav
2026-05-12 08:31:43 +00:00
parent 026be99393
commit 88bec71cf8
26 changed files with 3597 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { HealthController } from './common/health.controller';
import { AuthModule } from './auth/auth.module';
import { NodesModule } from './nodes/nodes.module';
@Module({
imports: [AuthModule, NodesModule],
controllers: [HealthController],
})
export class AppModule {}

View File

@@ -0,0 +1,19 @@
import { Body, Controller, Post } from '@nestjs/common';
@Controller('auth')
export class AuthController {
@Post('register')
register(@Body() body: Record<string, unknown>) {
return { status: 'todo', action: 'register', received: body };
}
@Post('login')
login(@Body() body: Record<string, unknown>) {
return { status: 'todo', action: 'login', received: body };
}
@Post('refresh')
refresh(@Body() body: Record<string, unknown>) {
return { status: 'todo', action: 'refresh', received: body };
}
}

View File

@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { AuthController } from './auth.controller';
@Module({
controllers: [AuthController],
})
export class AuthModule {}

View File

@@ -0,0 +1,9 @@
import { Controller, Get } from '@nestjs/common';
@Controller('healthz')
export class HealthController {
@Get()
get() {
return { ok: true, service: 'center' };
}
}

View File

@@ -0,0 +1,13 @@
import 'reflect-metadata';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api');
const port = process.env.PORT ? Number(process.env.PORT) : 7001;
await app.listen(port);
console.log(`Fabric.Backend.Center listening on :${port}`);
}
void bootstrap();

View File

@@ -0,0 +1,24 @@
import { Body, Controller, Get, Post } from '@nestjs/common';
type NodeRegistration = {
nodeId?: string;
name?: string;
endpoint?: string;
handshakeProof?: string;
};
@Controller('nodes')
export class NodesController {
private readonly nodes: NodeRegistration[] = [];
@Post('register')
register(@Body() body: NodeRegistration) {
this.nodes.push(body);
return { status: 'accepted', handshake: 'todo-verify-shared-secret', node: body };
}
@Get()
list() {
return { items: this.nodes };
}
}

View File

@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { NodesController } from './nodes.controller';
@Module({
controllers: [NodesController],
})
export class NodesModule {}