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

graphql api initialization #11

Merged
merged 6 commits into from
Apr 15, 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
41 changes: 41 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

.nx/cache
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- main
pull_request:
branches:
- main

permissions:
actions: read
Expand Down Expand Up @@ -42,3 +44,6 @@ jobs:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

- run: yarn nx affected -t lint test build

- run: yarn deploy:service-api
if: ${{ github.ref_name == 'main' }}
3,331 changes: 2,665 additions & 666 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .yarn/install-state.gz
Binary file not shown.
15 changes: 15 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,22 @@ export default tseslint.config(
//
},
rules: {
'unicorn/prevent-abbreviations': [
'error',
{
allowList: {
args: true,
Args: true,
ctx: true,
env: true,
Env: true,
},
},
],
//
},
},
{
ignores: ['**/dist/**', '**/*timestamp*.mjs'],
},
);
4 changes: 2 additions & 2 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
'{projects}/**/*.{ts,tsx}': (files) =>
'projects/**/*.{ts,tsx}': (files) =>
`yarn nx affected --target=typecheck --files=${files.join(',')}`,
'{projects}/**/*.{js,ts,jsx,tsx,json}': [
'projects/**/*.{js,ts,jsx,tsx,json}': [
(files) => `yarn nx affected:lint --files=${files.join(',')}`,
(files) => `yarn nx format:write --files=${files.join(',')}`,
],
Expand Down
11 changes: 9 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/tsconfig.test.json",
"!{projectRoot}/eslint.config.js"
],
"sharedGlobals": []
Expand Down Expand Up @@ -51,5 +51,12 @@
}
}
},
"nxCloudAccessToken": "YTRjZDAxOTYtOTI0Mi00ODFkLWFmM2ItYjM3NjBiMmRlZjVifHJlYWQ="
"nxCloudAccessToken": "YTRjZDAxOTYtOTI0Mi00ODFkLWFmM2ItYjM3NjBiMmRlZjVifHJlYWQ=",
"targetDefaults": {
"@nx/esbuild:esbuild": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
}
}
28 changes: 24 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,33 @@
"private": true,
"type": "module",
"scripts": {
"build": "nx run-many -t build",
"lint": "nx run-many -t lint",
"test": "nx run-many -t test",
"typecheck": "nx run-many -t typecheck",
"e2e": "nx run-many -t e2e",
"---PROJECT-SPECIFIC": "",
"build:app-web": "nx build app-web",
"build:service-api": "nx build service-api",
"deploy:service-api": "nx deploy service-api",
"dev:app-web": "nx serve app-web",
"dev:service-api": "nx serve service-api",
"e2e:app-web": "nx e2e app-web-e2e",
"test:app-web": "nx test app-web",
"test:service-api": "nx test service-api",
"---UTILITY": "",
"postinstall": "husky"
},
"devDependencies": {
"@commitlint/cli": "19.2.1",
"@eslint/js": "9.0.0",
"@graphql-tools/executor-http": "1.0.9",
"@nx/cypress": "18.2.4",
"@nx/devkit": "18.2.4",
"@nx/esbuild": "18.2.4",
"@nx/eslint": "18.2.4",
"@nx/js": "18.2.4",
"@nx/node": "18.2.4",
"@nx/playwright": "18.2.4",
"@nx/react": "18.2.4",
"@nx/vite": "18.2.4",
Expand All @@ -43,8 +52,9 @@
"@typescript-eslint/parser": "7.6.0",
"@vitejs/plugin-react": "4.2.1",
"@vitest/coverage-v8": "1.4.0",
"@vitest/ui": "1.4.0",
"@vitest/ui": "1.5.0",
"babel-plugin-styled-components": "2.1.4",
"esbuild": "0.20.2",
"eslint": "9.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jsx-a11y": "6.8.0",
Expand All @@ -59,16 +69,26 @@
"playwright": "1.43.0",
"prettier": "3.2.5",
"tslib": "2.6.2",
"typescript": "5.4.4",
"typescript": "5.4.5",
"typescript-eslint": "7.6.0",
"vite": "5.2.8",
"vitest": "1.4.0"
"vitest": "1.5.0"
},
"dependencies": {
"@hono/node-server": "1.10.0",
"@pothos/core": "3.41.0",
"envalid": "8.0.0",
"graphql": "16.8.1",
"graphql-yoga": "5.3.0",
"hono": "4.2.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-is": "18.2.0",
"styled-components": "6.1.8"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"dockerfile": {
"cache": "",
"distroless": true
}
}
20 changes: 11 additions & 9 deletions projects/app-web-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
"name": "app-web-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/app-web-e2e/src",
"sourceRoot": "projects/app-web-e2e/src",
"implicitDependencies": ["app-web"],
"// targets": "to see all targets run: nx show project app-web-e2e --web",
"targets": {
"targets": {
"typecheck": {
"executor": "nx:run-commands",
"options": {
"commands": ["tsc -p tsconfig.app.json --noEmit"],
"cwd": "projects/app-web",
"forwardAllArgs": false
}
"typecheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "tsc -p tsconfig.json --noEmit",
"forwardAllArgs": false
}
],
"cwd": "projects/app-web-e2e"
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions projects/app-web/project.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"name": "app-web",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/app-web/src",
"sourceRoot": "projects/app-web/src",
"projectType": "application",
"tags": [],
"// targets": "to see all targets run: nx show project app-web --web",
"targets": {
"typecheck": {
"executor": "nx:run-commands",
"options": {
"commands": ["tsc -p tsconfig.app.json --noEmit"],
"cwd": "projects/app-web",
"forwardAllArgs": false
"commands": [
{
"command": "tsc -p tsconfig.app.json --noEmit",
"forwardAllArgs": false
}
],
"cwd": "projects/app-web"
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions projects/app-web/vite.config.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
// import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -24,15 +24,18 @@ export default defineConfig({
host: 'localhost',
},

plugins: [react(), nxViteTsPaths()],
plugins: [
react(),
// nxViteTsPaths()
],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

build: {
outDir: './build/app-web',
outDir: './dist/app-web',
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
Expand All @@ -45,7 +48,7 @@ export default defineConfig({
dir: '../../node_modules/.vitest',
},
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
include: ['src/**/*.test.{ts,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/apps/app-web',
Expand Down
35 changes: 35 additions & 0 deletions projects/service-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-slim as build

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Copy application code
COPY --link . .

# Build application
RUN yarn run build:service-api

# Final stage for app image
FROM gcr.io/distroless/nodejs${NODE_VERSION}

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Copy built application
COPY --from=build /app/projects/service-api/dist /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "main.js" ]
17 changes: 17 additions & 0 deletions projects/service-api/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import rootConfig from '../../eslint.config.js';

export default [
...rootConfig,
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {},
},
];
22 changes: 22 additions & 0 deletions projects/service-api/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for service-api on 2024-04-15T15:06:25+10:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'service-api'
primary_region = 'syd'

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '256mb'
cpu_kind = 'shared'
cpus = 1
Loading
Loading