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

Retail Shopping Cart - Initial #33

Merged
merged 14 commits into from
May 15, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,49 @@ FodyWeavers.xsd
.idea/
*.sln.iml

# End of https://www.toptal.com/developers/gitignore/api/csharp
# End of https://www.toptal.com/developers/gitignore/api/csharp

# Additions because of nodejs, npm, expressjs, typescript, etc.

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

# Dependency directories
*/node_modules/
node_modules/
jspm_packages/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# vitepress
src/docs/.vitepress/dist
src/docs/.vitepress/cache
lib
5 changes: 5 additions & 0 deletions EventSourcingEcommerce.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discounts", "src\Pricing\Di
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discounts.Api", "src\Pricing\Discounts.Api\Discounts.Api.csproj", "{F42EAACF-D74A-4646-A311-AB9EB131AE8A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Retail", "Retail", "{91DC34A2-E5DC-4BDD-9BAE-6B9D1E8E0769}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shopping-cart", "shopping-cart", "{E8D6C05C-F653-42AA-BB9B-6E57251C7E99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -150,5 +154,6 @@ Global
{B96B27DD-C084-4310-9056-1E084795427C} = {E8FE7001-AFB6-4FB2-B922-BB6A203A652E}
{090F1820-19D9-464B-A0B0-415182075D9D} = {E8FE7001-AFB6-4FB2-B922-BB6A203A652E}
{F42EAACF-D74A-4646-A311-AB9EB131AE8A} = {E8FE7001-AFB6-4FB2-B922-BB6A203A652E}
{E8D6C05C-F653-42AA-BB9B-6E57251C7E99} = {91DC34A2-E5DC-4BDD-9BAE-6B9D1E8E0769}
EndGlobalSection
EndGlobal
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ services:

esdb:
image: eventstore/eventstore:24.2.0-jammy
# use this image if you're running ARM-based processor like an Apple M1
# image: eventstore/eventstore:24.2.0-alpha-arm64v8
container_name: ecomm_esdb
ports:
- '2113:2113'
Expand All @@ -12,7 +14,7 @@ services:
EVENTSTORE_RUN_PROJECTIONS: all
EVENTSTORE_START_STANDARD_PROJECTIONS: 'true'
EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true'
# EVENTSTORE__PLUGINS__CONNECTORS__ENABLED: 'true' -- only enabled in EE
# EVENTSTORE__PLUGINS__CONNECTORS__ENABLED: 'true' # only enabled in EE
command:
[
"--ExtIp=0.0.0.0", # Have ESDB listen on all ports not just localhost
Expand Down
6 changes: 6 additions & 0 deletions src/Retail/shopping-cart/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.git
/node_modules
.dockerignore
.env
Dockerfile
fly.toml
5 changes: 5 additions & 0 deletions src/Retail/shopping-cart/.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 src/Retail/shopping-cart/.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 src/Retail/shopping-cart/.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 src/Retail/shopping-cart/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.12.0
2 changes: 2 additions & 0 deletions src/Retail/shopping-cart/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/dist/
**/lib/
57 changes: 57 additions & 0 deletions src/Retail/shopping-cart/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"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/**"
]
}
]
}
24 changes: 24 additions & 0 deletions src/Retail/shopping-cart/.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 src/Retail/shopping-cart/.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"
}
]
}
44 changes: 44 additions & 0 deletions src/Retail/shopping-cart/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
FROM node:20.12.2-slim AS base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="development"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci --include=dev

# Copy application code
COPY --link src .

# Build application
RUN npm run build

# Remove development dependencies
RUN npm prune --omit=dev


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "start" ]
27 changes: 27 additions & 0 deletions src/Retail/shopping-cart/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:

esdb:
image: eventstore/eventstore:24.2.0-jammy
# use this image if you're running ARM-based processor like an Apple M1
# image: eventstore/eventstore:24.2.0-alpha-arm64v8
container_name: ecomm_esdb_retail
environment:
EVENTSTORE_INSECURE: 'true'
EVENTSTORE_CLUSTER_SIZE: 1
EVENTSTORE_RUN_PROJECTIONS: all
EVENTSTORE_START_STANDARD_PROJECTIONS: 'true'
EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP: 'true'
# EVENTSTORE__PLUGINS__CONNECTORS__ENABLED: 'true' # only enabled in EE
command:
[
"--ExtIp=0.0.0.0", # Have ESDB listen on all ports not just localhost
]
ports:
- '2113:2113'
- '1113:1113'
networks:
- esdb_network

networks:
esdb_network:
driver: bridge
10 changes: 10 additions & 0 deletions src/Retail/shopping-cart/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
Loading
Loading