spfn 0.2.0-beta.6 → 0.2.0-beta.60

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.
@@ -1,65 +0,0 @@
1
- /**
2
- * {{PASCAL_NAME}} Routes
3
- *
4
- * Auto-generated by SPFN CLI
5
- */
6
-
7
- import { createApp } from '@spfn/core/route';
8
- import { Transactional } from '@spfn/core/db';
9
- import { {{REPO_NAME}} } from '@/repositories/{{KEBAB_NAME}}.repository.js';
10
- import {
11
- list{{PASCAL_NAME}}Contract,
12
- create{{PASCAL_NAME}}Contract,
13
- } from '@/contracts/{{KEBAB_NAME}}.js';
14
-
15
- const app = createApp();
16
-
17
- /**
18
- * GET /{{ENTITY_NAME}}
19
- * List {{PASCAL_NAME}} items
20
- */
21
- app.bind(list{{PASCAL_NAME}}Contract, async (c) =>
22
- {
23
- const { limit = 20, offset = 0 } = c.query;
24
-
25
- const items = await {{REPO_NAME}}.findMany({ limit, offset });
26
-
27
- return c.json({
28
- items: items.map((item) => ({
29
- id: item.id,
30
- name: item.name,
31
- description: item.description,
32
- createdAt: item.createdAt.toISOString(),
33
- updatedAt: item.updatedAt.toISOString(),
34
- })),
35
- limit,
36
- offset,
37
- });
38
- });
39
-
40
- /**
41
- * POST /{{ENTITY_NAME}}
42
- * Create new {{PASCAL_NAME}}
43
- */
44
- app.bind(create{{PASCAL_NAME}}Contract, [Transactional()], async (c) =>
45
- {
46
- const body = await c.data();
47
-
48
- const item = await {{REPO_NAME}}.create({
49
- name: body.name,
50
- description: body.description,
51
- });
52
-
53
- return c.json(
54
- {
55
- id: item.id,
56
- name: item.name,
57
- description: item.description,
58
- createdAt: item.createdAt.toISOString(),
59
- updatedAt: item.updatedAt.toISOString(),
60
- },
61
- 201
62
- );
63
- });
64
-
65
- export default app;
@@ -1,13 +0,0 @@
1
- /**
2
- * {{FN_NAME_PASCAL}} Schema
3
- *
4
- * Creates isolated PostgreSQL schema for {{PACKAGE_NAME}} tables.
5
- * IMPORTANT: Export this schema so drizzle-kit can generate CREATE SCHEMA statement.
6
- *
7
- * Auto-generated by SPFN CLI
8
- */
9
-
10
- import { createFunctionSchema } from '@spfn/core/db';
11
-
12
- // ✅ Export schema to auto-generate CREATE SCHEMA in migrations
13
- export const {{SCHEMA_VAR_NAME}} = createFunctionSchema('{{PACKAGE_NAME}}');
@@ -1,67 +0,0 @@
1
- # Optimized Production Dockerfile for SPFN
2
- # Multi-stage build for smaller image size
3
-
4
- # Stage 1: Dependencies
5
- FROM node:20-alpine AS deps
6
- WORKDIR /app
7
-
8
- # Install pnpm
9
- RUN corepack enable pnpm
10
-
11
- # Copy dependency files
12
- COPY package.json pnpm-lock.yaml* ./
13
-
14
- # Install ALL dependencies (needed for build)
15
- RUN pnpm install --frozen-lockfile
16
-
17
- # Stage 2: Builder
18
- FROM node:20-alpine AS builder
19
- WORKDIR /app
20
-
21
- RUN corepack enable pnpm
22
-
23
- # Copy dependencies from deps stage
24
- COPY --from=deps /app/node_modules ./node_modules
25
- COPY . .
26
-
27
- # Build both Next.js and SPFN server
28
- RUN pnpm run spfn:build
29
-
30
- # Stage 3: Runner (Production)
31
- FROM node:20-alpine AS runner
32
- WORKDIR /app
33
-
34
- ENV NODE_ENV=production
35
-
36
- RUN corepack enable pnpm
37
-
38
- # Copy necessary files from builder
39
- COPY --from=builder /app/package.json ./package.json
40
- COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
41
- COPY --from=builder /app/.next ./.next
42
- COPY --from=builder /app/.spfn ./.spfn
43
- COPY --from=builder /app/public ./public
44
- COPY --from=builder /app/next.config.* ./
45
- COPY --from=builder /app/.env.local.example ./.env.local.example
46
-
47
- # Install PRODUCTION dependencies only
48
- RUN pnpm install --frozen-lockfile --prod
49
-
50
- # Create non-root user for security
51
- RUN addgroup --system --gid 1001 nodejs
52
- RUN adduser --system --uid 1001 nextjs
53
-
54
- # Change ownership
55
- RUN chown -R nextjs:nodejs /app
56
-
57
- USER nextjs
58
-
59
- # Expose both ports
60
- EXPOSE 3790 8790
61
-
62
- # Health check for SPFN API
63
- HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
64
- CMD node -e "require('http').get('http://localhost:8790/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
65
-
66
- # Start both Next.js and SPFN server
67
- CMD ["pnpm", "run", "spfn:start"]
@@ -1,22 +0,0 @@
1
- /**
2
- * Core Package Configuration
3
- *
4
- * @example
5
- * ```typescript
6
- * import { registry } from '@spfn/core/config';
7
- *
8
- * const env = registry.validate();
9
- * console.log(env.DB_POOL_MAX);
10
- * ```
11
- *
12
- * @module config
13
- */
14
-
15
- import { createEnvRegistry } from '@spfn/core/env';
16
- import { envSchema } from './schema';
17
-
18
- /**
19
- * Environment registry
20
- */
21
- const registry = createEnvRegistry(envSchema);
22
- export const env = registry.validate();
@@ -1,42 +0,0 @@
1
- /**
2
- * Environment Variable Schema
3
- *
4
- * Centralized schema definition for all environment variables.
5
- * This provides type safety, validation, and documentation for your application configuration.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { envSchema } from './config/schema';
10
- *
11
- * // Access validated environment variables
12
- * console.log(envSchema.DATABASE_URL.description);
13
- * console.log(envSchema.PORT.default);
14
- * ```
15
- *
16
- * @module config/schema
17
- */
18
-
19
- import {
20
- defineEnvSchema,
21
- envString,
22
- envNumber,
23
- } from '@spfn/core/env';
24
-
25
- /**
26
- * Application environment variable schema
27
- *
28
- * Add your environment variables here with proper types and validation.
29
- */
30
- export const envSchema = defineEnvSchema({
31
- // Example: API configuration
32
- API_KEY: envString({
33
- description: 'Third-party API key',
34
- required: true,
35
- }),
36
-
37
- // Example: Server port
38
- PORT: envNumber({
39
- description: 'Server port number',
40
- default: 8790,
41
- }),
42
- });