Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoApp committed Jan 22, 2025
1 parent bfe9bae commit 20266c5
Show file tree
Hide file tree
Showing 129 changed files with 6,623 additions and 5,628 deletions.
8 changes: 7 additions & 1 deletion .devcontainer/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ echo "export CODESPACE_WDS_SOCKET_PORT=443" >> ~/.bashrc
echo "printf \"\n\n☁️☁️☁️️ Anythink: Develop in the Cloud ☁️☁️☁️\n\"" >> ~/.bashrc
echo "printf \"\n\x1b[31m \x1b[1m👉 Type: \\\`docker compose up\\\` to run the project. 👈\n\n\"" >> ~/.bashrc

nohup bash -c "cd /wilco-agent && node agent.js &" >> /tmp/agent.log 2>&1
nohup bash -c "cd /wilco-agent && node agent.js &" >> /tmp/agent.log 2>&1

# Check if docker is installed
if command -v docker &> /dev/null
then
docker compose pull
fi
30 changes: 8 additions & 22 deletions .github/workflows/wilco-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,23 @@ jobs:
timeout-minutes: 10
name: Pr checks

services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
SECRET_KEY: secret
POSTGRES_DB: anythink-market
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out project
uses: actions/checkout@v2

- name: Use Python
uses: actions/setup-python@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
python-version: "3.9.13"
node-version: "16"

- uses: oNaiPs/secrets-to-env-action@v1
- name: Start MongoDB
uses: supercharge/[email protected]
with:
secrets: ${{ toJSON(secrets) }}
mongodb-version: "4.4"

- name: Setup Node for Wilco Checks
uses: actions/setup-node@v3
- uses: oNaiPs/secrets-to-env-action@v1
with:
node-version: "16"
secrets: ${{ toJSON(secrets) }}

- name: Wilco checks
id: Wilco
Expand Down
20 changes: 0 additions & 20 deletions backend/.dockerignore

This file was deleted.

123 changes: 25 additions & 98 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,110 +1,37 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
# Logs
logs
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/
.DS_Store

# Jupyter Notebook
.ipynb_checkpoints
npm-debug.log*

# pyenv
.python-version
# Runtime data
pids
*.pid
*.seed

# celery beat schedule file
celerybeat-schedule
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# SageMath parsed files
*.sage.py
# Coverage directory used by tools like istanbul
coverage

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Spyder project settings
.spyderproject
.spyproject
# node-waf configuration
.lock-wscript

# Rope project settings
.ropeproject
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# mkdocs documentation
/site
# Dependency directory
node_modules

# mypy
.mypy_cache/
# Optional npm cache directory
.npm

.idea/
.vscode/
# Optional REPL history
.node_repl_history

# Project
postgres-data
.idea
2 changes: 0 additions & 2 deletions backend/Dockerfile

This file was deleted.

15 changes: 5 additions & 10 deletions backend/Dockerfile.aws
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
FROM python:3.9.13
FROM node:16

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN pip install poetry==1.2.0

# Pre-install poetry packages
WORKDIR /usr/src
COPY backend ./backend
COPY .wilco ./.wilco

# Pre-install npm packages
WORKDIR /usr/src/backend
RUN poetry install
RUN poetry export -f "requirements.txt" --without-hashes --with-credentials > "requirements.txt"
RUN yarn install

21 changes: 0 additions & 21 deletions backend/LICENSE

This file was deleted.

40 changes: 16 additions & 24 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
Web routes
==========
# Anythink Market Backend

All routes are available on `/docs` or `/redoc` paths with Swagger or ReDoc.
The Anythink Market backend is Node web app written with [Express](https://expressjs.com/)

Project structure
=================
## Dependencies

Files related to application are in the `app` or `tests` directories. Application parts are:
- [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) - For generating JWTs used by authentication
- [mongoose](https://github.com/Automattic/mongoose) - For modeling and mapping MongoDB data to javascript
- [mongoose-unique-validator](https://github.com/blakehaswell/mongoose-unique-validator) - For handling unique validation errors in Mongoose. Mongoose only handles validation at the document level, so a unique index across a collection will throw an exception at the driver level. The `mongoose-unique-validator` plugin helps us by formatting the error like a normal mongoose `ValidationError`.
- [passport](https://github.com/jaredhanson/passport) - For handling user authentication
- [slug](https://github.com/dodo/node-slug) - For encoding titles into a URL-friendly format

app
├── api - web related stuff.
│   ├── dependencies - dependencies for routes definition.
│   ├── errors - definition of error handlers.
│   └── routes - web routes.
├── core - application configuration, startup events, logging.
├── db - db related stuff.
│   ├── migrations - manually written alembic migrations.
│   └── repositories - all crud stuff.
├── models - pydantic models for this application.
│   ├── domain - main models that are used almost everywhere.
│   └── schemas - schemas for using in web routes.
├── resources - strings that are used in web responses.
├── services - logic that is not just crud related.
└── main.py - FastAPI application creation and configuration.
## Application Structure

Project structure
=================
- `app.js` - The entry point to our application. This file defines our express server and connects it to MongoDB using mongoose. It also requires the routes and models we'll be using in the application.
- `config/` - This folder contains configuration for passport as well as a central location for configuration/environment variables.
- `routes/` - This folder contains the route definitions for our API.
- `models/` - This folder contains the schema definitions for our Mongoose models.

Project dependencies are managed by poetry (https://python-poetry.org), using venv (https://docs.python.org/3/library/venv.html).
## Error Handling

In `routes/api/index.js`, we define a error-handling middleware for handling Mongoose's `ValidationError`. This middleware will respond with a 422 status code and format the response to have [error messages the clients can understand](https://github.com/gothinkster/realworld/blob/master/API.md#errors-and-status-codes)
36 changes: 0 additions & 36 deletions backend/alembic.ini

This file was deleted.

Loading

0 comments on commit 20266c5

Please sign in to comment.