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-server #417

Merged
merged 10 commits into from
Apr 21, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 51 additions & 0 deletions apps/server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
node_modules/**
docs
.run
dist
.eslintrc.js
.prettierrc
http-client.env.json
README.md
.env
.editorconfig
**/Dockerfile

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

server/*.spec.js
kubernetes
e2e/
build

.fta.json
keploy-config.yaml
nodemon.json
openapi3.json
schema.gql
TODO.md
647 changes: 647 additions & 0 deletions apps/server/.editorconfig

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/server/.env
21 changes: 21 additions & 0 deletions apps/server/.fta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"output_limit": 250,
"score_cap": 90,
"exclude_directories": [
"__fixtures__",
"vendor",
"build",
"dist",
"coverage",
"node_modules",
"public"
],
"exclude_filenames": [
"*.test.{ts,tsx}"
],
"extensions": [
".ts"
],
"include_comments": false,
"exclude_under": 15
}
4 changes: 4 additions & 0 deletions apps/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/externals/generated/**
src/externals/compodoc/**
vendor/**
!.env
4 changes: 4 additions & 0 deletions apps/server/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
12 changes: 12 additions & 0 deletions apps/server/.run/dev.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dev" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="dev" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
3 changes: 3 additions & 0 deletions apps/server/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
45 changes: 45 additions & 0 deletions apps/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# `server`

## Goal

Overload server which as big amount of features as it is possible to resue as much code as it's possible in future,
program in decoupled way to allow easy testing and development, and have fun while doing it.

## Features

- **🍭 Eye Candies**, who would like to look at a boring wall of text all the time, since start of application it gives
you
nice and friendly developer feel, as all of us - keeping candies for ourselves so these features are disabled
for "serious" deployments.
- **"Where is the fucking documentation?"**, no fucking more fellas, there you have static documentation dedicated for
Angular-like projects (`compodoc`), static generation of `GraphQL` documentation, `Swagger` documentation for REST
API, and `eventsdoc` for event-driven applications. I would like to document websockets with `asyncapi` but sorry
ecosystem isn't ready for that yet. I mean... You still can completly do not give a fuck about documentation and will
hear such thing but I think you can say you tried at least lol

- [ ] Circuit Breaker
- [ ] Service Discovery
- [ ] Error Handling
- [ ] Exception Handling
- [ ] RxJS
- [ ] API Response Time
- [ ] Serialization
- [ ] Deserialization
- [ ] Prometheus Metrics
- [ ] Logging
- [ ] Concurrency Control
- [ ] Externalized Configuration
- [ ] Deployment Profiles
- [ ] OpenTracing
- [ ] XSS
- [ ] CORS
- [ ] CSRF
- [ ] OAuth 2.0
- [ ] GraphQL
- [ ] Rest

## Installation

```bash
$ pnpm install
```
2 changes: 2 additions & 0 deletions apps/server/bin/start-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export UV_THREADPOOL_SIZE=16 && node --harmony --harmony-shipping \
--enable-source-maps --max-old-space-size=6000 ../dist/src/main.js
55 changes: 55 additions & 0 deletions apps/server/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM node:18 AS BUILD

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

WORKDIR /tmp

RUN corepack enable

# Install pnpm
# RUN npm install -g pnpm && mkdir -p /usr/.pnpm-store

# Copy package.json and pnpm-lock.yaml and install dependencies
COPY ./package.json ./pnpm-lock.yaml ./

# Install dependencies with or without cache based on the USE_BUILDKIT environment variable
RUN pnpm install

# Copy Prisma schema and generate Prisma client
COPY ./prisma ./prisma/
RUN pnpm prisma generate

# Copy the rest of the application code
COPY . .

# Build the application
RUN pnpm run build

# ---------------------------------------------------------

FROM node:18 AS RUNTIME

RUN addgroup --system application_users && \
adduser --system --ingroup application_users application_user && \
mkdir /usr/bin/application && \
chown -R application_user:application_users /usr/bin/application && \
chmod -R 777 /usr/bin/application

WORKDIR /usr/bin/application

COPY --from=BUILD /tmp/node_modules /usr/bin/application/node_modules
COPY --from=BUILD /tmp/dist/src /usr/bin/application/bin
COPY --from=BUILD /tmp/package.json /usr/bin/application/package.json

RUN chmod -R 777 /usr/bin/application/bin

USER application_user

# Set the NODE_ENV to production as a default
ENV NODE_ENV production

EXPOSE 80
EXPOSE 443

CMD ["node", "/usr/bin/application/bin/main.js"]
Loading
Loading