nebula-starter-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -0
- package/dist/index.js +8 -0
- package/dist/run.js +112 -0
- package/dist/utils/addService.js +204 -0
- package/dist/utils/appName.js +75 -0
- package/dist/utils/deployNow.js +18 -0
- package/dist/utils/generateFiles.js +326 -0
- package/dist/utils/generateSchemas.js +58 -0
- package/dist/utils/listServices.js +24 -0
- package/dist/utils/replaceServiceNames.js +42 -0
- package/dist/utils/telemetryAddon.js +91 -0
- package/package.json +31 -0
- package/templates/core/audit/audit.controller.ts +125 -0
- package/templates/core/audit/audit.module.ts +10 -0
- package/templates/core/audit/audit.schema.ts +14 -0
- package/templates/core/audit/audit.service.ts +47 -0
- package/templates/core/auth/auth.controller.ts +207 -0
- package/templates/core/auth/auth.dto.ts +50 -0
- package/templates/core/auth/auth.module.ts +10 -0
- package/templates/core/auth/auth.service.ts +178 -0
- package/templates/core/auth/utils.ts +160 -0
- package/templates/core/constants/environment.db.ts +27 -0
- package/templates/core/constants/environment.module.ts +9 -0
- package/templates/core/constants/environment.service.ts +69 -0
- package/templates/core/core.controller.ts +35 -0
- package/templates/core/core.module.ts +22 -0
- package/templates/core/database/database.module.ts +20 -0
- package/templates/core/database/database.provider.ts +32 -0
- package/templates/core/database/database.service.ts +168 -0
- package/templates/core/database/database.types.ts +13 -0
- package/templates/core/filters/audit.decorator.ts +5 -0
- package/templates/core/filters/audit.interceptor.ts +74 -0
- package/templates/core/filters/http-exception.filter.ts +43 -0
- package/templates/core/filters/success-message.decorator.ts +5 -0
- package/templates/core/filters/success-response.interceptor.ts +35 -0
- package/templates/core/summarize/summarize.controller.ts +74 -0
- package/templates/core/summarize/summarize.dto.ts +13 -0
- package/templates/core/summarize/summarize.module.ts +9 -0
- package/templates/core/summarize/summarize.service.ts +54 -0
- package/templates/nest-cli.json +8 -0
- package/templates/package.json +52 -0
- package/templates/service/src/__name__.controller.ts +15 -0
- package/templates/service/src/__name__.module.ts +11 -0
- package/templates/service/src/__name__.schema.ts +15 -0
- package/templates/service/src/__name__.service.ts +12 -0
- package/templates/service/src/lambda.ts +60 -0
- package/templates/tsconfig.json +28 -0
- package/templates/ui/README.md +36 -0
- package/templates/ui/eslint.config.mjs +18 -0
- package/templates/ui/next.config.ts +8 -0
- package/templates/ui/package.json +33 -0
- package/templates/ui/postcss.config.mjs +7 -0
- package/templates/ui/public/file.svg +1 -0
- package/templates/ui/public/globe.svg +1 -0
- package/templates/ui/public/next.svg +1 -0
- package/templates/ui/public/vercel.svg +1 -0
- package/templates/ui/public/window.svg +1 -0
- package/templates/ui/src/app/LandingPage.tsx +98 -0
- package/templates/ui/src/app/ai/summarize/page.tsx +115 -0
- package/templates/ui/src/app/context/AuthContext.tsx +48 -0
- package/templates/ui/src/app/favicon.ico +0 -0
- package/templates/ui/src/app/globals.css +26 -0
- package/templates/ui/src/app/layout.tsx +37 -0
- package/templates/ui/src/app/page.tsx +7 -0
- package/templates/ui/src/app/services/page.tsx +99 -0
- package/templates/ui/src/components/Auth.css +252 -0
- package/templates/ui/src/components/Auth.tsx +455 -0
- package/templates/ui/src/components/Error.tsx +32 -0
- package/templates/ui/src/components/FormInput.tsx +77 -0
- package/templates/ui/src/components/Loading.tsx +10 -0
- package/templates/ui/src/components/Login.tsx +171 -0
- package/templates/ui/src/components/Popup.css +90 -0
- package/templates/ui/src/components/Signup.tsx +155 -0
- package/templates/ui/src/utils/axiosInstance.ts +37 -0
- package/templates/ui/src/utils/axiosRawInstance.ts +33 -0
- package/templates/ui/src/utils/util.constant.ts +0 -0
- package/templates/ui/src/utils/util.function.ts +165 -0
- package/templates/ui/src/utils/util.type.ts +64 -0
- package/templates/ui/src/utils/variables.ts +6 -0
- package/templates/ui/tailwind.config.js +8 -0
- package/templates/ui/tsconfig.json +43 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
BedrockRuntimeClient,
|
|
4
|
+
InvokeModelCommand,
|
|
5
|
+
} from '@aws-sdk/client-bedrock-runtime';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class SummarizeService {
|
|
9
|
+
private client: BedrockRuntimeClient;
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
this.client = new BedrockRuntimeClient({
|
|
13
|
+
region: process.env.BEDROCK_REGION,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async summarize(text: string) {
|
|
18
|
+
try {
|
|
19
|
+
const prompt = `
|
|
20
|
+
Summarize the following text in a short paragraph:
|
|
21
|
+
|
|
22
|
+
${text}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const command = new InvokeModelCommand({
|
|
26
|
+
modelId: process.env.BEDROCK_MODEL,
|
|
27
|
+
contentType: 'application/json',
|
|
28
|
+
accept: 'application/json',
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
anthropic_version: 'bedrock-2023-05-31',
|
|
31
|
+
max_tokens: 300,
|
|
32
|
+
messages: [
|
|
33
|
+
{
|
|
34
|
+
role: 'user',
|
|
35
|
+
content: prompt,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const response = await this.client.send(command);
|
|
42
|
+
|
|
43
|
+
const decoded = new TextDecoder().decode(response.body);
|
|
44
|
+
|
|
45
|
+
const parsed = JSON.parse(decoded);
|
|
46
|
+
|
|
47
|
+
return parsed.content[0].text;
|
|
48
|
+
} catch (err: any) {
|
|
49
|
+
console.error(err.message);
|
|
50
|
+
const msg = err?.message || JSON.stringify(err);
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "starter-kit-app",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"start": "nest start",
|
|
7
|
+
"start:dev": "nest start --watch",
|
|
8
|
+
"build": "nest build",
|
|
9
|
+
"format": "prettier --write \"src/**/*.{ts, tsx}\"",
|
|
10
|
+
"predeploy": "cd ui && npm install && npm run build && npm run export",
|
|
11
|
+
"deploy": "npm install && serverless deploy",
|
|
12
|
+
"teardown": "serverless remove",
|
|
13
|
+
"test": "NODE_ENV=test jest",
|
|
14
|
+
"test:watch": "jest --watch",
|
|
15
|
+
"test:cov": "jest --coverage",
|
|
16
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
17
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@aws-sdk/client-bedrock-runtime": "^3.1010.0",
|
|
21
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.888.0",
|
|
22
|
+
"@aws-sdk/client-dynamodb": "^3.948.0",
|
|
23
|
+
"@aws-sdk/lib-dynamodb": "^3.948.0",
|
|
24
|
+
"@nestjs/common": "^11.0.1",
|
|
25
|
+
"@nestjs/config": "^4.0.2",
|
|
26
|
+
"@nestjs/core": "^11.0.1",
|
|
27
|
+
"@nestjs/platform-express": "^11.0.1",
|
|
28
|
+
"@nestjs/serve-static": "^5.0.4",
|
|
29
|
+
"@nestjs/swagger": "^11.2.3",
|
|
30
|
+
"@vendia/serverless-express": "^4.12.6",
|
|
31
|
+
"reflect-metadata": "^0.2.2",
|
|
32
|
+
"rxjs": "^7.8.1",
|
|
33
|
+
"aws-lambda": "^1.0.7",
|
|
34
|
+
"class-transformer": "^0.5.1",
|
|
35
|
+
"class-validator": "^0.14.3",
|
|
36
|
+
"serverless": "^4.33.0",
|
|
37
|
+
"serverless-compose": "^2.4.0",
|
|
38
|
+
"serverless-esbuild": "^1.55.0",
|
|
39
|
+
"serverless-s3-sync": "^3.5.1",
|
|
40
|
+
"swagger-ui-express": "^5.0.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@nestjs/cli": "^11.0.0",
|
|
44
|
+
"@types/aws-lambda": "^8.10.159",
|
|
45
|
+
"@types/express": "^5.0.6",
|
|
46
|
+
"@types/node": "^25.0.6",
|
|
47
|
+
"serverless-offline": "^14.5.0",
|
|
48
|
+
"@serverless/compose": "^1.3.0",
|
|
49
|
+
"prettier": "^2.3.2",
|
|
50
|
+
"typescript": "^5.3.3"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Controller, Get } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
@Controller('__name__')
|
|
4
|
+
export class __Name__Controller {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
@Get()
|
|
8
|
+
async hello(): Promise<any> {
|
|
9
|
+
try {
|
|
10
|
+
return { message: 'Welcome to the __Name__ Service' };
|
|
11
|
+
} catch (error) {
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { __Name__Controller } from './__name__.controller';
|
|
3
|
+
import { __Name__Service } from './__name__.service';
|
|
4
|
+
import { CoreModule } from '../../../core/core.module';
|
|
5
|
+
|
|
6
|
+
@Module({
|
|
7
|
+
imports: [CoreModule],
|
|
8
|
+
controllers: [__Name__Controller],
|
|
9
|
+
providers: [__Name__Service],
|
|
10
|
+
})
|
|
11
|
+
export class __Name__Module {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const __NAME___TABLE =
|
|
2
|
+
process.env.__NAME___TABLE || '__appName__-__name__';
|
|
3
|
+
|
|
4
|
+
export const __NAME___TABLE_SCHEMA = {
|
|
5
|
+
tableName: __NAME___TABLE,
|
|
6
|
+
hashKey: 'id',
|
|
7
|
+
rangeKey: 'createdAt',
|
|
8
|
+
gsis: [
|
|
9
|
+
{
|
|
10
|
+
indexName: 'userId-__name__Id-index',
|
|
11
|
+
partitionKey: 'userId',
|
|
12
|
+
sortKey: '__name__Id',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { NestFactory, Reflector } from '@nestjs/core';
|
|
3
|
+
import { __Name__Module } from './__name__.module';
|
|
4
|
+
import serverlessExpress from '@vendia/serverless-express';
|
|
5
|
+
import { Callback, Handler } from 'aws-lambda';
|
|
6
|
+
import { ConfigureResult } from '@vendia/serverless-express/src/configure';
|
|
7
|
+
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
8
|
+
import { ValidationPipe } from '@nestjs/common';
|
|
9
|
+
import { HttpExceptionFilter } from '@core/filters/http-exception.filter';
|
|
10
|
+
import { SuccessResponseInterceptor } from '@core/filters/success-response.interceptor';
|
|
11
|
+
import { AuditInterceptor } from '@core/filters/audit.interceptor';
|
|
12
|
+
import { AuditService } from '@core/audit/audit.service';
|
|
13
|
+
|
|
14
|
+
let server:
|
|
15
|
+
| (Handler<any, any> & ConfigureResult<any, any>)
|
|
16
|
+
| ((arg0: any, arg1: any) => any);
|
|
17
|
+
|
|
18
|
+
async function bootstrap() {
|
|
19
|
+
const app = await NestFactory.create(__Name__Module);
|
|
20
|
+
const config = new DocumentBuilder()
|
|
21
|
+
.setTitle('__Name__ API')
|
|
22
|
+
.setDescription('__Name__ Service API')
|
|
23
|
+
.setVersion('1.0')
|
|
24
|
+
.build();
|
|
25
|
+
|
|
26
|
+
app.enableCors({
|
|
27
|
+
origin: '*',
|
|
28
|
+
methods: '*',
|
|
29
|
+
});
|
|
30
|
+
app.useGlobalPipes(
|
|
31
|
+
new ValidationPipe({
|
|
32
|
+
whitelist: true, // strips unknown properties
|
|
33
|
+
forbidNonWhitelisted: true, // throws error for extra fields
|
|
34
|
+
transform: true, // auto-transform payloads to DTO classes
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
app.useGlobalFilters(new HttpExceptionFilter());
|
|
38
|
+
app.useGlobalInterceptors(new SuccessResponseInterceptor());
|
|
39
|
+
app.useGlobalInterceptors(
|
|
40
|
+
new AuditInterceptor(app.get(Reflector), app.get(AuditService)),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const document = SwaggerModule.createDocument(app, config);
|
|
44
|
+
SwaggerModule.setup('api-docs', app, document);
|
|
45
|
+
await app.init();
|
|
46
|
+
return serverlessExpress({
|
|
47
|
+
app: app.getHttpAdapter().getInstance(),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const handler = async (
|
|
52
|
+
event: any,
|
|
53
|
+
context: any,
|
|
54
|
+
callback: Callback<any>,
|
|
55
|
+
) => {
|
|
56
|
+
if (!server) {
|
|
57
|
+
server = await bootstrap();
|
|
58
|
+
}
|
|
59
|
+
return server(event, context, callback);
|
|
60
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"moduleResolution": "Node",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"rootDir": ".",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"paths": {
|
|
13
|
+
"@core/*": ["core/*"],
|
|
14
|
+
"@services/*": ["services/*"],
|
|
15
|
+
"@infra/*": ["infra/*"],
|
|
16
|
+
"@ui/*": ["ui/src/*"]
|
|
17
|
+
},
|
|
18
|
+
"emitDecoratorMetadata": true,
|
|
19
|
+
"experimentalDecorators": true,
|
|
20
|
+
"useDefineForClassFields": false,
|
|
21
|
+
"skipLibCheck": true
|
|
22
|
+
},
|
|
23
|
+
"include": [
|
|
24
|
+
"core/**/*",
|
|
25
|
+
"services/**/*"
|
|
26
|
+
],
|
|
27
|
+
"exclude": ["node_modules", "test", "templates", "**/*spec.ts"],
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
First, run the development server:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run dev
|
|
9
|
+
# or
|
|
10
|
+
yarn dev
|
|
11
|
+
# or
|
|
12
|
+
pnpm dev
|
|
13
|
+
# or
|
|
14
|
+
bun dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
18
|
+
|
|
19
|
+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
|
20
|
+
|
|
21
|
+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
|
22
|
+
|
|
23
|
+
## Learn More
|
|
24
|
+
|
|
25
|
+
To learn more about Next.js, take a look at the following resources:
|
|
26
|
+
|
|
27
|
+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
28
|
+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
29
|
+
|
|
30
|
+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
|
31
|
+
|
|
32
|
+
## Deploy on Vercel
|
|
33
|
+
|
|
34
|
+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
35
|
+
|
|
36
|
+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
3
|
+
import nextTs from "eslint-config-next/typescript";
|
|
4
|
+
|
|
5
|
+
const eslintConfig = defineConfig([
|
|
6
|
+
...nextVitals,
|
|
7
|
+
...nextTs,
|
|
8
|
+
// Override default ignores of eslint-config-next.
|
|
9
|
+
globalIgnores([
|
|
10
|
+
// Default ignores of eslint-config-next:
|
|
11
|
+
".next/**",
|
|
12
|
+
"out/**",
|
|
13
|
+
"build/**",
|
|
14
|
+
"next-env.d.ts",
|
|
15
|
+
]),
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export default eslintConfig;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start",
|
|
9
|
+
"export": "npm run build",
|
|
10
|
+
"deploy": "npm run build",
|
|
11
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
12
|
+
"lint": "eslint"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"next": "16.1.6",
|
|
16
|
+
"date-fns": "^4.1.0",
|
|
17
|
+
"react": "^19.2.3",
|
|
18
|
+
"react-dom": "^19.2.3",
|
|
19
|
+
"axios": "^1.12.1",
|
|
20
|
+
"react-icons": "^5.5.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@tailwindcss/postcss": "^4",
|
|
24
|
+
"@types/node": "^20",
|
|
25
|
+
"@types/react": "^19",
|
|
26
|
+
"@types/react-dom": "^19",
|
|
27
|
+
"eslint": "^9",
|
|
28
|
+
"eslint-config-next": "16.1.6",
|
|
29
|
+
"tailwindcss": "^4",
|
|
30
|
+
"prettier": "^2.3.2",
|
|
31
|
+
"typescript": "^5"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import Authz from "@/components/Auth";
|
|
4
|
+
import { appName, apiUrl, appServices } from "@/utils/variables";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { FaSignOutAlt } from "react-icons/fa";
|
|
7
|
+
import { useAuth } from "./context/AuthContext";
|
|
8
|
+
|
|
9
|
+
export default function LandingPage() {
|
|
10
|
+
console.log(appName);
|
|
11
|
+
console.log(apiUrl);
|
|
12
|
+
console.log(appServices);
|
|
13
|
+
const [mode, setMode] = useState('login');
|
|
14
|
+
const { login, isLoggedIn, logout } = useAuth();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="min-h-screen flex">
|
|
18
|
+
|
|
19
|
+
{/* LEFT SIDE */}
|
|
20
|
+
<div className="hidden lg:flex w-1/2 bg-gradient-to-br from-blue-600 to-purple-600 text-white p-16 flex-col justify-center">
|
|
21
|
+
|
|
22
|
+
<h1 className="text-5xl font-bold mb-6">
|
|
23
|
+
Welcome to {appName}
|
|
24
|
+
</h1>
|
|
25
|
+
|
|
26
|
+
<p className="text-lg opacity-90 mb-10">
|
|
27
|
+
The all-in-one platform that transforms how you work
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<div className="space-y-8">
|
|
31
|
+
|
|
32
|
+
<Feature
|
|
33
|
+
title="Lightning Fast Performance"
|
|
34
|
+
description="Experience blazing-fast load times and seamless interactions powered by cutting-edge technology."
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
<Feature
|
|
38
|
+
title="Team Collaboration"
|
|
39
|
+
description="Work together in real-time with your team. Share, comment, and collaborate effortlessly."
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<Feature
|
|
43
|
+
title="Enterprise Security"
|
|
44
|
+
description="Bank-level encryption and security protocols to keep your data safe and compliant."
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
{/* RIGHT SIDE */}
|
|
51
|
+
<div className="flex w-full lg:w-1/2 items-center justify-center bg-gray-50 p-10">
|
|
52
|
+
|
|
53
|
+
<div className="w-full max-w-md bg-white p-10 rounded-xl shadow-lg">
|
|
54
|
+
|
|
55
|
+
<h2 className="text-3xl font-bold mb-2">{mode === 'login' ? 'Welcome back' : mode === 'signup' ? 'Welcome' : 'Hi,'}</h2>
|
|
56
|
+
|
|
57
|
+
<p className="text-gray-500 mb-8">
|
|
58
|
+
{mode === 'login' ? 'Enter your credentials to access your account' : mode === 'singup' ? 'Please fill in your details to come on board' : 'Feel free to explore'}
|
|
59
|
+
</p>
|
|
60
|
+
<Authz setMode={setMode} />
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div className="relative">
|
|
65
|
+
{isLoggedIn && (
|
|
66
|
+
<>
|
|
67
|
+
<span className="cursor-pointer mr-4 absolute right-8 top-8">
|
|
68
|
+
<FaSignOutAlt
|
|
69
|
+
color="#e83245"
|
|
70
|
+
onClick={() => {
|
|
71
|
+
// localStorage.removeItem('email');
|
|
72
|
+
logout();
|
|
73
|
+
window.location.reload();
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
</span>
|
|
77
|
+
</>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
function Feature({ title, description }: any) {
|
|
86
|
+
return (
|
|
87
|
+
<div className="flex gap-4">
|
|
88
|
+
<div className="bg-white/20 p-3 rounded-lg">
|
|
89
|
+
⚡
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div>
|
|
93
|
+
<h3 className="font-semibold text-lg">{title}</h3>
|
|
94
|
+
<p className="text-sm opacity-90">{description}</p>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// app/ai/summarize/page.tsx
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
import { useAuth } from "@/app/context/AuthContext";
|
|
5
|
+
import axiosInstance from "@/utils/axiosInstance";
|
|
6
|
+
import { appServices } from "@/utils/variables";
|
|
7
|
+
import { AxiosResponse } from "axios";
|
|
8
|
+
import { useRouter } from "next/navigation";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { FaSignOutAlt } from "react-icons/fa";
|
|
11
|
+
|
|
12
|
+
export default function SummarizePage() {
|
|
13
|
+
const { login, isLoggedIn, logout } = useAuth();
|
|
14
|
+
const router = useRouter()
|
|
15
|
+
const [text, setText] = useState("");
|
|
16
|
+
const [summary, setSummary] = useState<string | null>(null);
|
|
17
|
+
const [loading, setLoading] = useState(false);
|
|
18
|
+
const [error, setError] = useState<string | null>(null);
|
|
19
|
+
const [errors, setErrors] = useState({});
|
|
20
|
+
|
|
21
|
+
const handleSummarize = async () => {
|
|
22
|
+
if (!text.trim()) return;
|
|
23
|
+
setLoading(true);
|
|
24
|
+
setError(null);
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
setErrors({});
|
|
28
|
+
console.log('Calling summarize API');
|
|
29
|
+
// setLoading(true);
|
|
30
|
+
const res: AxiosResponse = await axiosInstance.post(
|
|
31
|
+
`${appServices}/summarize/summarize`,
|
|
32
|
+
{ text },
|
|
33
|
+
{
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
console.log('Summary data', res.data?.data);
|
|
40
|
+
setSummary(res.data?.data);
|
|
41
|
+
} catch (err: any) {
|
|
42
|
+
setLoading(false);
|
|
43
|
+
setErrors(err.message);
|
|
44
|
+
console.log(err.message);
|
|
45
|
+
} finally {
|
|
46
|
+
setLoading(false);
|
|
47
|
+
}
|
|
48
|
+
// try {
|
|
49
|
+
// const res = await fetch("/api/ai/summarize", {
|
|
50
|
+
// method: "POST",
|
|
51
|
+
// headers: { "Content-Type": "application/json" },
|
|
52
|
+
// body: JSON.stringify({ text }),
|
|
53
|
+
// });
|
|
54
|
+
|
|
55
|
+
// if (!res.ok) throw new Error("Failed to summarize text");
|
|
56
|
+
|
|
57
|
+
// const data = await res.json();
|
|
58
|
+
// setSummary(data.summary);
|
|
59
|
+
// } catch (err: any) {
|
|
60
|
+
// setError(err.message || "Something went wrong");
|
|
61
|
+
// } finally {
|
|
62
|
+
// setLoading(false);
|
|
63
|
+
// }
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
if (!isLoggedIn){
|
|
67
|
+
router.push('/')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div className="min-h-screen flex flex-col items-center justify-start p-8 bg-gray-50">
|
|
72
|
+
<div className="">
|
|
73
|
+
{isLoggedIn && (
|
|
74
|
+
<>
|
|
75
|
+
<span className="cursor-pointer mr-4 absolute right-8 top-8">
|
|
76
|
+
<FaSignOutAlt
|
|
77
|
+
color="#e83245"
|
|
78
|
+
onClick={() => {
|
|
79
|
+
logout();
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
</span>
|
|
83
|
+
</>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
<h1 className="text-3xl font-bold mb-6">AI Text Summarizer</h1>
|
|
87
|
+
|
|
88
|
+
<textarea
|
|
89
|
+
className="w-full max-w-2xl h-40 p-4 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 mb-4"
|
|
90
|
+
placeholder="Paste text here to summarize..."
|
|
91
|
+
value={text}
|
|
92
|
+
onChange={(e) => setText(e.target.value)}
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<button
|
|
96
|
+
onClick={handleSummarize}
|
|
97
|
+
className="bg-blue-600 text-white px-6 py-3 rounded-lg hover:bg-blue-700 transition mb-6 cursor-pointer"
|
|
98
|
+
disabled={loading}
|
|
99
|
+
>
|
|
100
|
+
{loading ? "Summarizing..." : "Summarize"}
|
|
101
|
+
</button>
|
|
102
|
+
|
|
103
|
+
{error && (
|
|
104
|
+
<div className="text-red-600 mb-4">{error}</div>
|
|
105
|
+
)}
|
|
106
|
+
|
|
107
|
+
{summary && (
|
|
108
|
+
<div className="w-full max-w-2xl bg-white p-4 rounded-lg shadow-md border border-gray-200">
|
|
109
|
+
<h2 className="font-semibold text-lg mb-2">Summary:</h2>
|
|
110
|
+
<p className="text-gray-700">{summary}</p>
|
|
111
|
+
</div>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/set-state-in-effect */
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
import { createContext, useContext, useState, ReactNode, useEffect } from "react";
|
|
5
|
+
|
|
6
|
+
interface AuthContextType {
|
|
7
|
+
isLoggedIn: boolean;
|
|
8
|
+
login: () => void;
|
|
9
|
+
logout: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
|
13
|
+
|
|
14
|
+
export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
|
15
|
+
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(false);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (localStorage === undefined) return;
|
|
19
|
+
const storedAuthState = localStorage.getItem("email");
|
|
20
|
+
setIsLoggedIn(storedAuthState === "true");
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
const login = () => {
|
|
24
|
+
if (localStorage === undefined) return;
|
|
25
|
+
setIsLoggedIn(true);
|
|
26
|
+
localStorage.setItem("email", "true");
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const logout = () => {
|
|
30
|
+
if (localStorage === undefined) return;
|
|
31
|
+
setIsLoggedIn(false);
|
|
32
|
+
localStorage.removeItem("email");
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<AuthContext.Provider value={{ isLoggedIn, login, logout }}>
|
|
37
|
+
{children}
|
|
38
|
+
</AuthContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const useAuth = () => {
|
|
43
|
+
const context = useContext(AuthContext);
|
|
44
|
+
if (context === undefined) {
|
|
45
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
46
|
+
}
|
|
47
|
+
return context;
|
|
48
|
+
};
|
|
Binary file
|