Skip to content

Commit 31504c9

Browse files
committed
Initial commit
0 parents  commit 31504c9

37 files changed

+8822
-0
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DATABASE_URL=postgresql://username:password@localhost:5432/retrofunding
2+
SYNCHRONIZE=false
3+
LOGGING=true
4+
PORT=4000
5+
INDEXER_URL=https://grants-stack-indexer-v2.gitcoin.co/
6+
NODE_ENV=development

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
node_modules/
3+
src/index.ts

.eslintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"standard-with-typescript",
8+
"prettier"
9+
],
10+
"parserOptions": {
11+
"ecmaVersion": "latest",
12+
"sourceType": "module"
13+
},
14+
"rules": {}
15+
}

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
# Checkout the repository
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
# Set up Node.js
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
26+
# Install dependencies
27+
- name: Install dependencies
28+
run: npm install
29+
30+
# Run linting
31+
- name: Run ESLint
32+
run: npm run lint
33+
34+
# Check formatting with Prettier
35+
- name: Check Prettier formatting
36+
run: npm run prettier -- --check
37+
38+
# Run the build
39+
- name: Run build
40+
run: npm run build

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.idea/
2+
.vscode/
3+
node_modules/
4+
build/
5+
tmp/
6+
temp/
7+
logs/
8+
.env
9+
.eslintcache
10+
schema.graphql

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/migration

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid",
10+
"endOfLine": "lf"
11+
}

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# retrofunding-api
2+
3+
## Structure
4+
5+
```
6+
.
7+
├── README.md # Project documentation
8+
├── package-lock.json # Dependency lock file
9+
├── package.json # Project metadata and dependencies
10+
├── src # Source code for the application
11+
│ ├── controller # Routing controller logic
12+
│ ├── entity # TypeORM entities, defining database schemas and relations
13+
│ ├── ext # External API integrations
14+
│ ├── migration # Database migrations for schema changes
15+
│ ├── routes # API routes
16+
│ ├── service # Business logic and service functions
17+
│ ├── data-source.ts # Database connection setup and configuration
18+
│ ├── index.ts # Application entry point
19+
│ ├── postgraphile.config.ts # Postgraphile configuration
20+
│ ├── repository.ts # Repositories for data access logic
21+
│ ├── swagger.ts # Optional: Swagger setup in TypeScript
22+
│ └── utils.ts # Utility functions and helper methods
23+
└── tsconfig.json # TypeScript configuration
24+
```
25+
26+
## Getting Started
27+
28+
1. **Basic Setup**:
29+
```bash
30+
npm install
31+
npm run prepare
32+
```
33+
2. **Configure Environment Variables**:
34+
Create a `.env` file in the root of the project and set the necessary environment variables for database connection.
35+
3. **Setting up your databas**:
36+
- Connect as admin `psql -U your_admin_username -h your_database_host -p your_database_port`
37+
- In `psql` shell, run
38+
```shell
39+
CREATE DATABASE your_database_name;
40+
CREATE ROLE your_database_username WITH LOGIN PASSWORD 'your_database_password';
41+
GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_database_username;
42+
```
43+
4. **Handling Migration**
44+
- Make changes to the entity
45+
- Generate migration with `npm run generate --name=MigrationName`
46+
- Run migration with `npm run migrate`
47+
- If you need to revert last migration, `npm run revert`
48+
5. **Run the Development Server**:
49+
```bash
50+
npm run dev
51+
```
52+
6. **API Overview**
53+
- Visit `http://localhost:3000/api-docs`
54+
55+
**Note**
56+
57+
- For [Logging.md](./src//logger/logger.md) to understand use winston for logging
58+
- For Try catch handling done via [catchError](./src/utils.ts)
59+
- All routes are documented using [swagger](./src/swagger.ts)
60+
- Postgraphile endpoint is hosted at `http://localhost:3000/graphiql`
61+
62+
```
63+
POST Endpoint
64+
------
65+
router.post('/pools', syncPool);
66+
router.post('/allocations', allocations)
67+
```

0 commit comments

Comments
 (0)