mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat(frontend): setup
This commit is contained in:
parent
db62d5d908
commit
f14eda16ac
33 changed files with 15076 additions and 22 deletions
|
|
@ -3,13 +3,15 @@ import { ConfigModule } from "@nestjs/config";
|
|||
import { AuthenticationModule } from "./authentication/authentication.module";
|
||||
import { DatabaseModule } from "./database/database.module";
|
||||
import { ConnectionsModule } from "./connections/connections.module";
|
||||
import { FrontendModule } from './frontend/frontend.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
DatabaseModule,
|
||||
AuthenticationModule,
|
||||
ConnectionsModule
|
||||
ConnectionsModule,
|
||||
FrontendModule
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Module } from "@nestjs/common";
|
||||
import { JwtStrategy } from "./jwt.strategy";
|
||||
import { PassportModule } from "@nestjs/passport";
|
||||
import { JwtStrategy } from "./jwt.strategy";
|
||||
|
||||
@Module({
|
||||
imports: [PassportModule.register({ defaultStrategy: "jwt" })],
|
||||
|
|
|
|||
|
|
@ -12,14 +12,12 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
|
|||
cache: true,
|
||||
rateLimit: true,
|
||||
jwksRequestsPerMinute: 5,
|
||||
jwksUri: `${config.get<string>(
|
||||
"JWT_AUTH0_DOMAIN"
|
||||
)}.well-known/jwks.json`
|
||||
jwksUri: `${config.get<string>("AUTH0_DOMAIN")}.well-known/jwks.json`
|
||||
}),
|
||||
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
audience: config.get<string>("JWT_AUTH0_AUDIENCE"),
|
||||
issuer: config.get<string>("JWT_AUTH0_DOMAIN"),
|
||||
audience: config.get<string>("AUTH0_AUDIENCE"),
|
||||
issuer: config.get<string>("AUTH0_DOMAIN"),
|
||||
algorithms: ["RS256"]
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
import { Controller } from "@nestjs/common";
|
||||
import { Controller, Get, UseGuards } from "@nestjs/common";
|
||||
import { AuthGuard } from "@nestjs/passport";
|
||||
|
||||
@Controller("connections")
|
||||
export class ConnectionsController {}
|
||||
@Controller("api/v1/connections")
|
||||
export class ConnectionsController {
|
||||
@Get()
|
||||
@UseGuards(AuthGuard("jwt"))
|
||||
get() {
|
||||
return { msg: "Success!" };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
18
src/frontend/frontend.controller.spec.ts
Normal file
18
src/frontend/frontend.controller.spec.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { FrontendController } from './frontend.controller';
|
||||
|
||||
describe('Frontend Controller', () => {
|
||||
let controller: FrontendController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [FrontendController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<FrontendController>(FrontendController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
7
src/frontend/frontend.controller.ts
Normal file
7
src/frontend/frontend.controller.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { Controller, Get } from "@nestjs/common";
|
||||
|
||||
@Controller("")
|
||||
export class FrontendController {
|
||||
@Get()
|
||||
index() {}
|
||||
}
|
||||
7
src/frontend/frontend.module.ts
Normal file
7
src/frontend/frontend.module.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { FrontendController } from './frontend.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [FrontendController]
|
||||
})
|
||||
export class FrontendModule {}
|
||||
|
|
@ -1,8 +1,15 @@
|
|||
import { NestFactory } from "@nestjs/core";
|
||||
import { NestExpressApplication } from "@nestjs/platform-express";
|
||||
import { join } from "path";
|
||||
import { AppModule } from "./app.module";
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||
|
||||
app.useStaticAssets(join(__dirname, "frontend", "public"));
|
||||
app.setBaseViewsDir(join(__dirname, "frontend", "views"));
|
||||
app.setViewEngine("mustache");
|
||||
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue