Skip to content

Commit 26522c3

Browse files
committed
Added initial code for optimistic concurrency samples
1 parent b931e73 commit 26522c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+18708
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/dist/
2+
**/node_modules/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
end_of_line = lf
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/node_modules/*
2+
# build artifacts
3+
dist/*coverage/*
4+
5+
# data definition files
6+
**/*.d.ts
7+
8+
# custom definition files
9+
/src/types/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"env": {
3+
"es2020": true,
4+
"node": true
5+
},
6+
"extends": ["plugin:prettier/recommended"],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"ecmaVersion": 11,
10+
"sourceType": "module"
11+
},
12+
"plugins": ["@typescript-eslint"],
13+
"rules": {},
14+
"settings": {
15+
"import/resolver": {
16+
"typescript": {}
17+
}
18+
}
19+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 2,
3+
"singleQuote": true
4+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug",
6+
"type": "node",
7+
"request": "launch",
8+
"runtimeExecutable": "npm",
9+
"runtimeArgs": ["run-script", "start", "--", "--inspect-brk=9229"],
10+
"port": 9229
11+
},
12+
{
13+
"name": "Debug Server",
14+
"type": "node",
15+
"request": "launch",
16+
"runtimeExecutable": "npm",
17+
"runtimeArgs": ["run-script", "start:server", "--", "--inspect-brk=9229"],
18+
"port": 9229
19+
},
20+
{
21+
"name": "Debug Subscription",
22+
"type": "node",
23+
"request": "launch",
24+
"runtimeExecutable": "npm",
25+
"runtimeArgs": [
26+
"run-script",
27+
"start:subscription",
28+
"--",
29+
"--inspect-brk=9229"
30+
],
31+
"port": 9229
32+
},
33+
{
34+
"name": "Jest all tests",
35+
"type": "node",
36+
"request": "launch",
37+
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
38+
"args": ["--verbose", "-i", "--no-cache", "--watchAll"],
39+
"console": "integratedTerminal",
40+
"internalConsoleOptions": "neverOpen"
41+
},
42+
{
43+
"name": "Jest current test",
44+
"type": "node",
45+
"request": "launch",
46+
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
47+
"args": [
48+
"--verbose",
49+
"-i",
50+
"--no-cache",
51+
"--runTestsByPath",
52+
"${relativeFile}",
53+
"--watchAll"
54+
],
55+
"console": "integratedTerminal",
56+
"internalConsoleOptions": "neverOpen"
57+
}
58+
]
59+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"editor.formatOnPaste": false,
3+
"editor.formatOnSave": true,
4+
5+
"editor.codeActionsOnSave": {
6+
// For ESLint
7+
"source.fixAll.eslint": true
8+
},
9+
10+
"editor.tabSize": 2,
11+
12+
"files.exclude": {
13+
"node_modules/": true,
14+
"dist/": true
15+
},
16+
"files.eol": "\n"
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "build:ts:watch",
7+
"group": "build",
8+
"problemMatcher": [],
9+
"label": "npm: build:ts:watch",
10+
"detail": "tsc --watch"
11+
}
12+
]
13+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
########################################
2+
# First stage of multistage build
3+
########################################
4+
# Use Build image with label `builder
5+
########################################
6+
# use
7+
FROM node:lts-alpine AS builder
8+
9+
# Setup working directory for project
10+
WORKDIR /app
11+
12+
COPY ./package.json ./
13+
COPY ./package-lock.json ./
14+
COPY ./tsconfig.json ./
15+
16+
# install node modules
17+
# use `npm ci` instead of `npm install`
18+
# to install exact version from `package-lock.json`
19+
RUN npm ci
20+
21+
# Copy project files
22+
COPY src ./src
23+
24+
# Build project
25+
RUN npm run build:ts
26+
27+
# sets environment to production
28+
# and removes packages from devDependencies
29+
RUN npm prune --production
30+
31+
########################################
32+
# Second stage of multistage build
33+
########################################
34+
# Use other build image as the final one
35+
# that won't have source codes
36+
########################################
37+
FROM node:lts-alpine
38+
39+
# Setup working directory for project
40+
WORKDIR /app
41+
42+
# Copy published in previous stage binaries
43+
# from the `builder` image
44+
COPY --from=builder /app/dist ./dist
45+
COPY --from=builder /app/node_modules ./node_modules
46+
47+
# Set URL that App will be exposed
48+
EXPOSE 5000
49+
50+
# sets entry point command to automatically
51+
# run application on `docker run`
52+
ENTRYPOINT ["node", "./dist/index.js"]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import dotenv from 'dotenv';
2+
import convict from 'convict';
3+
4+
dotenv.config();
5+
6+
const convictConfig = convict({
7+
env: {
8+
format: ['prod', 'dev', 'test'],
9+
default: 'dev',
10+
arg: 'nodeEnv',
11+
env: 'NODE_ENV',
12+
},
13+
eventStoreDB: {
14+
connectionString: {
15+
format: String,
16+
default: 'esdb://localhost:2113?tls=false&throwOnAppendFailure=false',
17+
arg: 'ESDB_CONNECTION_STRING',
18+
env: 'ESDB_CONNECTION_STRING',
19+
},
20+
},
21+
mongoDB: {
22+
connectionString: {
23+
format: String,
24+
default: 'mongodb://localhost:27017',
25+
arg: 'MONGODB_CONNECTION_STRING',
26+
env: 'MONGODB_CONNECTION_STRING',
27+
},
28+
databaseName: {
29+
format: String,
30+
default: 'mongodb://localhost:27017',
31+
arg: 'MONGODB_DATABASE_NAME',
32+
env: 'MONGODB_DATABASE_NAME',
33+
},
34+
},
35+
});
36+
37+
const env = convictConfig.get('env');
38+
convictConfig.loadFile(`./config/${env}.json`);
39+
40+
convictConfig.validate({ allowed: 'strict' }); // throws error if config does not conform to schema
41+
42+
export const config = convictConfig.getProperties(); // so we can operate with a plain old JavaScript object and abstract away

0 commit comments

Comments
 (0)