Skip to content

Commit

Permalink
Added simple sample
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Jul 9, 2024
1 parent b238ce9 commit 2f5bf6c
Show file tree
Hide file tree
Showing 25 changed files with 4,475 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ await users.deleteOne({ _id: cruella._id });
const anitaFromDb = await users.findOne({ _id: anitaId });

// Finding more
users = await users.find({ age: { $lt: 40 } });
const usersFromDb = await users.find({ age: { $lt: 40 } });
```

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

// Finding more
users = await users.find({ age: { $lt: 40 } }).toArray();
const usersFromDb = await users.find({ age: { $lt: 40 } }).toArray();
```

## How does it work?
Expand Down
4 changes: 4 additions & 0 deletions samples/simple/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules/
**/dist/
**/*.d.ts
/src/types/
5 changes: 5 additions & 0 deletions samples/simple/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
end_of_line = lf
11 changes: 11 additions & 0 deletions samples/simple/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/node_modules/*
# build artifacts
dist/*coverage/*

# data definition files
**/*.d.ts

# custom definition files
/src/types/

!.eslintrc.js
33 changes: 33 additions & 0 deletions samples/simple/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"env": {
"es2023": true,
"node": true
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
],
"@typescript-eslint/no-misused-promises": ["off"],
"@typescript-eslint/prefer-namespace-keyword": "off"
},
"settings": {
"import/resolver": {
"typescript": {}
}
}
}
1 change: 1 addition & 0 deletions samples/simple/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.1
2 changes: 2 additions & 0 deletions samples/simple/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/dist/
**/lib/
4 changes: 4 additions & 0 deletions samples/simple/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"singleQuote": true
}
1 change: 1 addition & 0 deletions samples/simple/.vscode/Node.js.code-profile

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions samples/simple/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug current file",
"type": "node",
"request": "launch",

// Debug current file in VSCode
"program": "${file}",

/*
Path to tsx binary
Assuming locally installed
*/
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/tsx",

/*
Open terminal when debugging starts (Optional)
Useful to see console.logs
*/
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",

// Files to exclude from debugger (e.g. call stack)
"skipFiles": [
// Node.js internal core modules
"<node_internals>/**",

// Ignore all dependencies (optional)
"${workspaceFolder}/node_modules/**"
]
},
{
"name": "Debug All Tests (Node)",
"type": "node",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"test",
"--inspect-brk=9229",
"--preserve-symlinks"
], // Use --inspect-brk for debugging
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"cwd": "${workspaceFolder}",
"sourceMaps": true,
"smartStep": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**",
"node_modules/@event-driven.io/emmett-expressjs/**/*.*"
]
}
]
}
24 changes: 24 additions & 0 deletions samples/simple/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,

"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit",
"source.addMissingImports": "always"
},

"editor.tabSize": 2,

"files.exclude": {
"**/*.tsbuildinfo": true
},
"files.eol": "\n",

"typescript.preferences.importModuleSpecifier": "relative",
"eslint.workingDirectories": [{ "mode": "auto" }],
"debug.javascript.terminalOptions": {
"nodeVersionHint": 20
}
}
13 changes: 13 additions & 0 deletions samples/simple/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build:ts:watch",
"group": "build",
"problemMatcher": [],
"label": "npm: build:ts:watch",
"detail": "tsc --watch"
}
]
}
53 changes: 53 additions & 0 deletions samples/simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[![](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)

![](./docs/public/logo.png)

# Emmett - Sample showing event-sourced WebApi with Express.js and EventStoreDB

Read more in [Emmett getting started guide](https://event-driven-io.github.io/emmett/getting-started.html).

## Prerequisities

Sample require EventStoreDB, you can start it by running

```bash
docker-compose up
```

You need to install packages with

```bash
npm install
```

## Running

Just run

```bash
npm run start
```

## Running inside Docker

To build application:

```bash
docker-compose --profile app build
```

To run application:

```bash
docker-compose --profile app up
```

### Testing

You can either run tests with

```
npm run test
```

Or manually with prepared [.http](.http) file
30 changes: 30 additions & 0 deletions samples/simple/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3.8" # Specify Docker Compose version

services:
postgres:
image: postgres:15.1-alpine
ports:
- "5432:5432"
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres

pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:[email protected]}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-postgres}
- PGADMIN_CONFIG_SERVER_MODE=False
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
ports:
- "${PGADMIN_PORT:-5050}:80"
entrypoint: /bin/sh -c "chmod 600 /pgpass; /entrypoint.sh;"
user: root
volumes:
- ./docker/pgAdmin/pgpass:/pgpass
- ./docker/pgAdmin/servers.json:/pgadmin4/servers.json
depends_on:
- postgres
restart: unless-stopped
Loading

0 comments on commit 2f5bf6c

Please sign in to comment.