Skip to content

Commit 2f5bf6c

Browse files
committed
Added simple sample
1 parent b238ce9 commit 2f5bf6c

25 files changed

+4475
-14
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ await users.deleteOne({ _id: cruella._id });
5454
const anitaFromDb = await users.findOne({ _id: anitaId });
5555

5656
// Finding more
57-
users = await users.find({ age: { $lt: 40 } });
57+
const usersFromDb = await users.find({ age: { $lt: 40 } });
5858
```
5959

6060
Or use MongoDB compliant shim:
@@ -93,7 +93,7 @@ await users.deleteOne({ _id: cruella._id });
9393
const anitaFromDb = await users.findOne({ _id: anitaId });
9494

9595
// Finding more
96-
users = await users.find({ age: { $lt: 40 } }).toArray();
96+
const usersFromDb = await users.find({ age: { $lt: 40 } }).toArray();
9797
```
9898

9999
## How does it work?

samples/simple/.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules/
2+
**/dist/
3+
**/*.d.ts
4+
/src/types/

samples/simple/.editorconfig

+5
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

samples/simple/.eslintignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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/
10+
11+
!.eslintrc.js

samples/simple/.eslintrc.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"env": {
3+
"es2023": true,
4+
"node": true
5+
},
6+
"plugins": ["@typescript-eslint"],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
11+
"plugin:prettier/recommended"
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"ecmaVersion": 2023,
16+
"sourceType": "module",
17+
"project": "./tsconfig.json"
18+
},
19+
"rules": {
20+
"no-unused-vars": "off",
21+
"@typescript-eslint/no-unused-vars": [
22+
"error",
23+
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
24+
],
25+
"@typescript-eslint/no-misused-promises": ["off"],
26+
"@typescript-eslint/prefer-namespace-keyword": "off"
27+
},
28+
"settings": {
29+
"import/resolver": {
30+
"typescript": {}
31+
}
32+
}
33+
}

samples/simple/.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.11.1

samples/simple/.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/dist/
2+
**/lib/

samples/simple/.prettierrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 2,
3+
"singleQuote": true
4+
}

samples/simple/.vscode/Node.js.code-profile

+1
Large diffs are not rendered by default.

samples/simple/.vscode/launch.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug current file",
6+
"type": "node",
7+
"request": "launch",
8+
9+
// Debug current file in VSCode
10+
"program": "${file}",
11+
12+
/*
13+
Path to tsx binary
14+
Assuming locally installed
15+
*/
16+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",
17+
18+
/*
19+
Open terminal when debugging starts (Optional)
20+
Useful to see console.logs
21+
*/
22+
"console": "integratedTerminal",
23+
"internalConsoleOptions": "neverOpen",
24+
25+
// Files to exclude from debugger (e.g. call stack)
26+
"skipFiles": [
27+
// Node.js internal core modules
28+
"<node_internals>/**",
29+
30+
// Ignore all dependencies (optional)
31+
"${workspaceFolder}/node_modules/**"
32+
]
33+
},
34+
{
35+
"name": "Debug All Tests (Node)",
36+
"type": "node",
37+
"request": "launch",
38+
"skipFiles": ["<node_internals>/**"],
39+
"runtimeExecutable": "npm",
40+
"runtimeArgs": [
41+
"run-script",
42+
"test",
43+
"--inspect-brk=9229",
44+
"--preserve-symlinks"
45+
], // Use --inspect-brk for debugging
46+
"console": "integratedTerminal",
47+
"internalConsoleOptions": "neverOpen",
48+
"cwd": "${workspaceFolder}",
49+
"sourceMaps": true,
50+
"smartStep": true,
51+
"resolveSourceMapLocations": [
52+
"${workspaceFolder}/**",
53+
"!**/node_modules/**",
54+
"node_modules/@event-driven.io/emmett-expressjs/**/*.*"
55+
]
56+
}
57+
]
58+
}

samples/simple/.vscode/settings.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnPaste": false,
4+
"editor.formatOnSave": true,
5+
6+
"editor.codeActionsOnSave": {
7+
"source.organizeImports": "explicit",
8+
"source.fixAll.eslint": "explicit",
9+
"source.addMissingImports": "always"
10+
},
11+
12+
"editor.tabSize": 2,
13+
14+
"files.exclude": {
15+
"**/*.tsbuildinfo": true
16+
},
17+
"files.eol": "\n",
18+
19+
"typescript.preferences.importModuleSpecifier": "relative",
20+
"eslint.workingDirectories": [{ "mode": "auto" }],
21+
"debug.javascript.terminalOptions": {
22+
"nodeVersionHint": 20
23+
}
24+
}

samples/simple/.vscode/tasks.json

+13
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+
}

samples/simple/README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[![](https://dcbadge.vercel.app/api/server/fTpqUTMmVa?style=flat)](https://discord.gg/fTpqUTMmVa) [<img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" height="20px" />](https://www.linkedin.com/in/oskardudycz/) [![Github Sponsors](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/oskardudycz/)](https://github.com/sponsors/oskardudycz/) [![blog](https://img.shields.io/badge/blog-event--driven.io-brightgreen)](https://event-driven.io/?utm_source=event_sourcing_nodejs) [![blog](https://img.shields.io/badge/%F0%9F%9A%80-Architecture%20Weekly-important)](https://www.architecture-weekly.com/?utm_source=event_sourcing_nodejs)
2+
3+
![](./docs/public/logo.png)
4+
5+
# Emmett - Sample showing event-sourced WebApi with Express.js and EventStoreDB
6+
7+
Read more in [Emmett getting started guide](https://event-driven-io.github.io/emmett/getting-started.html).
8+
9+
## Prerequisities
10+
11+
Sample require EventStoreDB, you can start it by running
12+
13+
```bash
14+
docker-compose up
15+
```
16+
17+
You need to install packages with
18+
19+
```bash
20+
npm install
21+
```
22+
23+
## Running
24+
25+
Just run
26+
27+
```bash
28+
npm run start
29+
```
30+
31+
## Running inside Docker
32+
33+
To build application:
34+
35+
```bash
36+
docker-compose --profile app build
37+
```
38+
39+
To run application:
40+
41+
```bash
42+
docker-compose --profile app up
43+
```
44+
45+
### Testing
46+
47+
You can either run tests with
48+
49+
```
50+
npm run test
51+
```
52+
53+
Or manually with prepared [.http](.http) file

samples/simple/docker-compose.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: "3.8" # Specify Docker Compose version
2+
3+
services:
4+
postgres:
5+
image: postgres:15.1-alpine
6+
ports:
7+
- "5432:5432"
8+
environment:
9+
- POSTGRES_DB=postgres
10+
- POSTGRES_PASSWORD=postgres
11+
- POSTGRES_USER=postgres
12+
13+
pgadmin:
14+
container_name: pgadmin_container
15+
image: dpage/pgadmin4
16+
environment:
17+
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:[email protected]}
18+
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-postgres}
19+
- PGADMIN_CONFIG_SERVER_MODE=False
20+
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
21+
ports:
22+
- "${PGADMIN_PORT:-5050}:80"
23+
entrypoint: /bin/sh -c "chmod 600 /pgpass; /entrypoint.sh;"
24+
user: root
25+
volumes:
26+
- ./docker/pgAdmin/pgpass:/pgpass
27+
- ./docker/pgAdmin/servers.json:/pgadmin4/servers.json
28+
depends_on:
29+
- postgres
30+
restart: unless-stopped

0 commit comments

Comments
 (0)