Skip to content

Commit

Permalink
refactor: new server setup
Browse files Browse the repository at this point in the history
  • Loading branch information
francislagares committed May 24, 2023
1 parent 2857751 commit 58034f2
Show file tree
Hide file tree
Showing 47 changed files with 2,734 additions and 317 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ node_modules/

# production
build
dist
logs

# misc
.DS_Store
Expand All @@ -24,6 +26,15 @@ build
.env.production.local
.eslintcache

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# MongoDB replica sets
mongodb_cluster

# Redis Volumes
redis_data
105 changes: 104 additions & 1 deletion client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,109 @@
{
"root": true,
"env": {
"browser": true,
"node": true,
"es6": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2021,
"sourceType": "module"
},
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"plugins": ["import", "jsx-a11y", "react-hooks", "jest-dom", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:jest-dom/recommended",
"prettier"
],
"rules": {
"prettier/prettier": "error",
"camelcase": "off",
"import/prefer-default-export": "off",
"react/prop-types": "off",
"react/jsx-filename-extension": "off",
"react/jsx-props-no-spreading": "off",
"react/no-unused-prop-types": "off",
"react/react-in-jsx-scope": "off",
"react/require-default-props": "off",
// eslint-plugin-import rules
"import/named": "error",
"import/namespace": "error",
"import/default": "error",
"import/export": "error",
"import/order": [
"error",
{
"newlines-between": "always",
"groups": [
["builtin"],
["external"],
["parent", "internal", "sibling", "index", "unknown"]
],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"pathGroups": [
{
"pattern": "react",
"group": "builtin",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["builtin"]
}
],
"import/extensions": ["error", "never"],
"quotes": "off",
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": ["Link"],
"specialLink": ["hrefLeft", "hrefRight"],
"aspects": ["invalidHref", "preferButton"]
}
]
},
"overrides": [
{
"files": "**/*.+(ts|tsx)",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint/eslint-plugin"],
"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-use-before-define": [0],
"@typescript-eslint/no-use-before-define": [1],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off"
}
}
],
"settings": {
"import/resolver": {
"typescript": {
"project": "."
}
},
"react": {
"version": "detect"
}
}
}

/* {
"extends": ["../.eslintrc.json"],
"parserOptions": {
" project": "./tsconfig.json"
}
}
} */
3 changes: 3 additions & 0 deletions client/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/// <reference types="cypress" />

import '@testing-library/cypress/add-commands';

// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
Expand Down
4 changes: 4 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@storybook/react": "^7.0.14",
"@storybook/react-vite": "^7.0.14",
"@storybook/testing-library": "^0.1.0",
"@testing-library/cypress": "^9.0.0",
"@testing-library/dom": "^9.3.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
Expand All @@ -42,6 +43,9 @@
"@vitest/ui": "^0.31.1",
"c8": "^7.13.0",
"cypress": "^12.12.0",
"eslint-plugin-jest-dom": "^4.0.3",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react-hooks": "^4.6.0",
"identity-obj-proxy": "^3.0.0",
"jest-environment-jsdom": "^29.5.0",
"msw": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion client/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, test } from 'vitest';
import { render, screen } from '@testing-library/react';
import { describe } from 'vitest';

import App from './App';

Expand Down
1 change: 1 addition & 0 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"jsx": "react-jsx",
"module": "esnext"
},
"types": ["cypress", "@testing-library/cypress"],
"include": ["./src/**/*.ts", "./src/**/*.tsx"]
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
"server": "yarn workspace @mern-monorepo/server start:dev",
"client": "yarn workspace @mern-monorepo/client dev",
"start": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\"",
"build": "yarn build:clean && yarn build:tsc",
"build:tsc": "tsc && tsc-alias",
"build:clean": "rimraf dist; exit 0",
"test:ci": "vitest run",
"test:watch": "vitest watch --ui",
"test:coverage": "vitest run --coverage",
"test:api": "yarn workspace @mern-monorepo/server test",
"test:client": "yarn workspace @mern-monorepo/client test",
"e2e:client": "yarn workspace @mern-monorepo/client cypress:run",
"build-server": "yarn workspace @mern-monorepo/server build",
"build-server": "yarn workspace @mern-monorepo/server deploy:dev",
"build-client": "yarn workspace @mern-monorepo/client build",
"deploy": "concurrently --kill-others-on-fail \"yarn build-client\" \"yarn server\"",
"type-check": "tsc --project tsconfig.json --pretty --noEmit",
Expand All @@ -46,9 +49,11 @@
"jest": "^29.5.0",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"typescript": "^5.0.4",
"vite": "^4.3.8",
"vitest": "^0.31.1"
"vitest": "^0.31.1",
"vitest-mock-extended": "^1.1.3"
},
"config": {
"commitizen": {
Expand Down
1 change: 1 addition & 0 deletions server/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
38 changes: 38 additions & 0 deletions server/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"ignorePatterns": ["node_modules", "build", "coverage"],
"env": {
"es6": true,
"node": true
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"no-var": "error",
"semi": "error",
"no-multi-spaces": "error",
"space-in-parens": "error",
"no-multiple-empty-lines": "error",
"prefer-const": "error",
"max-lines-per-function": ["warn", 40],
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"prettier/prettier": "error"
}
}
/*
{
"extends": ["../.eslintrc.json"],
"parserOptions": {
" project": "./tsconfig.json"
}
} */
64 changes: 64 additions & 0 deletions server/docker-compose-mongodb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: "3.9"

networks:
mongodb-cluster-net:

services:
mongo0:
image: mongo
container_name: mongo0
command: >
mongod
--replSet rs0
--bind_ip localhost,mongo0
ports:
- 27017:27017
restart: unless-stopped
volumes:
- ./mongodb_cluster/db0:/data/db
networks:
- mongodb-cluster-net

mongo1:
image: mongo
container_name: mongo1
command: >
mongod
--replSet rs0
--bind_ip localhost,mongo1
ports:
- 27018:27017
restart: unless-stopped
volumes:
- ./mongodb_cluster/db1:/data/db
networks:
- mongodb-cluster-net

mongo2:
image: mongo
container_name: mongo2
command: >
mongod
--replSet rs0
--bind_ip localhost,mongo2
ports:
- 27019:27017
restart: unless-stopped
volumes:
- ./mongodb_cluster/db2:/data/db
networks:
- mongodb-cluster-net

mongo-rs-init:
image: mongo
container_name: mongo-rs-init
depends_on:
- mongo0
- mongo1
- mongo2
entrypoint: ["bash", "replica_set_init.sh"]
restart: on-failure
volumes:
- ./scripts/replica_set_init.sh:/usr/local/bin/replica_set_init.sh:ro
networks:
- mongodb-cluster-net
26 changes: 26 additions & 0 deletions server/docker-compose-redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3.9"
services:
redis:
container_name: redis-cache
image: redis
ports:
- 6379:6379
volumes:
- ./redis_data:/data
redis-commander:
container_name: redis-commander
hostname: redis-commander
image: ghcr.io/joeferner/redis-commander:latest
environment:
- REDIS_HOSTS=local:redis:6379
ports:
- '8081:8081'

networks:
redis:
name: redis

volumes:
redis_data:
name: redis_data
driver: local
Loading

0 comments on commit 58034f2

Please sign in to comment.