Skip to content

Commit

Permalink
add tsc to build
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-im committed Aug 1, 2023
1 parent 2156aa6 commit fe64da1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ jobs:
with:
node-version: "14.x"

- name: Build server
run: cd ./server && npm install && tsc

- name: Install dependencies
run: cd ./client && npm install

- name: Build
run: cd ./client && npm run build

- name: Copy
run: cd ./client && cp -r build/ ../server/src
run: cd ./client && cp -r build/ ../server/dist

deploy:
needs: [testing, building]
Expand Down
81 changes: 44 additions & 37 deletions server/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'node:path';
import path from 'path';
import Fastify, { FastifyReply, FastifyRequest } from 'fastify';
import cors from '@fastify/cors';
import jwt from '@fastify/jwt';
Expand All @@ -11,7 +11,14 @@ import logRoutes from './modules/log/log.route';
import { userSchemas } from './modules/user/user.auth.schema';
import { projectSchemas } from './modules/project/project.schema';
import {
DONATE_URL, LOG_URL, NOTIFICATION_URL, PAYMENT_URL, PLAN_URL, PROJECT_URL, STATUS_URL, USER_URL
DONATE_URL,

Check failure on line 14 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
LOG_URL,

Check failure on line 15 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
NOTIFICATION_URL,

Check failure on line 16 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
PAYMENT_URL,

Check failure on line 17 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
PLAN_URL,

Check failure on line 18 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
PROJECT_URL,

Check failure on line 19 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
STATUS_URL,

Check failure on line 20 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
USER_URL,

Check failure on line 21 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
} from './util/urls';
import planRoutes from './modules/plan/plan.route';
import notificationRoutes from './modules/notification/notification.route';
Expand All @@ -21,53 +28,53 @@ import donateRoutes from './modules/donate/donate.route';
import './jobs';

declare module 'fastify' {
export interface FastifyInstance {
// eslint-disable-next-line
registredUser: any;
}
export interface FastifyInstance {
// eslint-disable-next-line
registredUser: any;
}
}

declare module '@fastify/jwt' {
interface FastifyJWT {
user: {
id: string;
};
}
interface FastifyJWT {
user: {
id: string;
};
}
}

// eslint-disable-next-line
function serverBuilder(options: { [key: string]: any } = {}) {
const logger = options.logger || true;
const server = Fastify({ logger });
const logger = options.logger || true;

Check failure on line 47 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2
const server = Fastify({ logger });

Check failure on line 48 in server/src/server.ts

View workflow job for this annotation

GitHub Actions / testing

Expected indentation of 4 spaces but found 2

server.decorate('registredUser', registredUserHook);
for (const schema of [...userSchemas, ...projectSchemas]) {
server.addSchema(schema);
}
server.decorate('registredUser', registredUserHook);
for (const schema of [...userSchemas, ...projectSchemas]) {
server.addSchema(schema);
}

server.register(fastifyStatic, {
root: path.join(__dirname, 'build'),
wildcard: false,
});
server.register(fastifyStatic, {
root: path.join(__dirname, 'build'),
wildcard: false,
});

server.get('/*', (request: FastifyRequest, reply: FastifyReply) => {
// @ts-ignore
reply.sendFile('index.html');
});
server.get('/*', (request: FastifyRequest, reply: FastifyReply) => {
// @ts-ignore
reply.sendFile('index.html');
});

server.register(jwt, { secret: <string>process.env.SECRET_OR_KEY });
server.register(cors, {});
server.register(statusRoutes, { prefix: STATUS_URL });
server.register(userRoutes, { prefix: USER_URL });
server.register(projectRoutes, { prefix: PROJECT_URL });
server.register(logRoutes, { prefix: LOG_URL });
server.register(planRoutes, { prefix: PLAN_URL });
server.register(notificationRoutes, { prefix: NOTIFICATION_URL });
server.register(paymentRoutes, { prefix: PAYMENT_URL });
server.register(donateRoutes, { prefix: DONATE_URL });
server.register(senderRoutes, { prefix: 'api/v1/send' });
server.register(jwt, { secret: <string>process.env.SECRET_OR_KEY });
server.register(cors, {});
server.register(statusRoutes, { prefix: STATUS_URL });
server.register(userRoutes, { prefix: USER_URL });
server.register(projectRoutes, { prefix: PROJECT_URL });
server.register(logRoutes, { prefix: LOG_URL });
server.register(planRoutes, { prefix: PLAN_URL });
server.register(notificationRoutes, { prefix: NOTIFICATION_URL });
server.register(paymentRoutes, { prefix: PAYMENT_URL });
server.register(donateRoutes, { prefix: DONATE_URL });
server.register(senderRoutes, { prefix: 'api/v1/send' });

return server;
return server;
}

export default serverBuilder;

0 comments on commit fe64da1

Please sign in to comment.