Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add api #21

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
11 changes: 11 additions & 0 deletions apps/api/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'api',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/api',
};
24 changes: 24 additions & 0 deletions apps/api/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "api",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/api/src",
"projectType": "application",
"targets": {
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "api:build"
},
"configurations": {
"development": {
"buildTarget": "api:build:development"
},
"production": {
"buildTarget": "api:build:production"
}
}
}
},
"tags": []
}
Empty file added apps/api/src/assets/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions apps/api/src/main.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('`api`', () => {
it('should work', () => {
expect(true).toBe(true);
});
});
21 changes: 21 additions & 0 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
*/

import express from 'express';
import * as path from 'path';

const app = express();

app.use('/assets', express.static(path.join(__dirname, 'assets')));

app.get('/api', (req, res) => {
res.send({ message: 'Welcome to api!' });
});

const port = process.env.PORT || 3333;
const server = app.listen(port, () => {
console.log(`Listening at http://localhost:${port}/api`);
});
server.on('error', console.error);
10 changes: 10 additions & 0 deletions apps/api/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node", "express"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
16 changes: 16 additions & 0 deletions apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
}
}
14 changes: 14 additions & 0 deletions apps/api/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}
19 changes: 19 additions & 0 deletions apps/api/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { NxWebpackPlugin } = require('@nx/webpack');
const { join } = require('path');

module.exports = {
output: {
path: join(__dirname, '../../dist/apps/api'),
},
plugins: [
new NxWebpackPlugin({
target: 'node',
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
assets: ['./src/assets'],
optimization: false,
outputHashing: 'none',
}),
],
};
15 changes: 12 additions & 3 deletions apps/web/market-client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"name": "next"
}
],
"types": ["jest", "node"]
"types": [
"jest",
"node"
]
},
"include": [
"**/*.ts",
Expand All @@ -25,7 +28,13 @@
"**/*.jsx",
"../../../apps/web/market-client/.next/types/**/*.ts",
"../../../dist/apps/web/market-client/.next/types/**/*.ts",
"next-env.d.ts"
"next-env.d.ts",
".next/types/**/*.ts"
],
"exclude": ["node_modules", "jest.config.ts", "**/*.spec.ts", "**/*.test.ts"]
"exclude": [
"node_modules",
"jest.config.ts",
"**/*.spec.ts",
"**/*.test.ts"
]
}
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"@nx/js:swc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
}
}
Loading
Loading