Skip to content

Commit

Permalink
Merge pull request #1 from Gearbox-protocol/lint
Browse files Browse the repository at this point in the history
feat: add lint; reorganize code
  • Loading branch information
essserrr authored Jan 5, 2025
2 parents 47b8191 + a1f4820 commit f7c414b
Show file tree
Hide file tree
Showing 46 changed files with 4,065 additions and 2,501 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
lib
*.d.ts
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"root": true,
"extends": ["@gearbox-protocol/eslint-config/react"],
"parserOptions": {
"project": ["./tsconfig.json"],
},
"rules": {
"no-void": ["error", { "allowAsStatement": true }],
},
}
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Fly Deploy
on:
push:
branches:
- main # change to main if needed
- main # change to main if needed
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --build-target app --dockerfile docker/Dockerfile.flyio --ha=false
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
node_modules
.env
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
62 changes: 31 additions & 31 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"branches": [
{
"name": "main"
}
"branches": [
{
"name": "main"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"successComment": false,
"failTitle": false
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"successComment": false,
"failTitle": false
}
[
"@codedependant/semantic-release-docker",
{
"dockerTags": [
"{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
"{{version}}"
],
[
"@codedependant/semantic-release-docker",
{
"dockerTags": [
"{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
"{{version}}"
],
"dockerArgs": {
"PACKAGE_VERSION": "{{version}}"
},
"dockerImage": "apy-server",
"dockerRegistry": "ghcr.io",
"dockerProject": "gearbox-protocol",
"dockerBuildQuiet": false,
"dockerLogin": false
}
]
"dockerArgs": {
"PACKAGE_VERSION": "{{version}}"
},
"dockerImage": "apy-server",
"dockerRegistry": "ghcr.io",
"dockerProject": "gearbox-protocol",
"dockerBuildQuiet": false,
"dockerLogin": false
}
]
}
]
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"nomicfoundation.hardhat-solidity",
"dbaeumer.vscode-eslint"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"eslint.validate": ["javascript", "typescript"],
"files.eol": "\n"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ npx ts-node main.ts

### Deploying changes via github actions
- Create a PR to the main branch.
- On merger the changes will be applied to apy-server.fly.dev
- On merger the changes will be applied to apy-server.fly.dev
6 changes: 3 additions & 3 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as esbuild from 'esbuild';
import { createBuildSettings } from './settings.mjs';
import * as esbuild from "esbuild";
import { createBuildSettings } from "./settings.mjs";

const settings = createBuildSettings({ minify: true });

await esbuild.build(settings);
await esbuild.build(settings);
28 changes: 14 additions & 14 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { build } from "esbuild";

build({
entryPoints: ["main.ts"],
outdir: "build",
bundle: true,
platform: "node",
format: "esm",
outExtension: { ".js": ".mjs" },
target: ["node20"],
sourcemap: "external",
banner: {
js: `
entryPoints: ["main.ts"],
outdir: "build",
bundle: true,
platform: "node",
format: "esm",
outExtension: { ".js": ".mjs" },
target: ["node20"],
sourcemap: "external",
banner: {
js: `
import { createRequire } from 'module';
import { fileURLToPath } from 'url';
const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
`,
},
external: ["node-pty"],
},
external: ["node-pty"],
}).catch(e => {
console.error(e);
process.exit(1);
console.error(e);
process.exit(1);
});
67 changes: 38 additions & 29 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
import express from 'express';
import dotenv from 'dotenv';
import { Fetcher, } from './src/fetcher';
import cors from "cors";
dotenv.config();
import { config } from "dotenv";
import express, { json } from "express";

import { checkResp, getAll, getByChainAndToken, getRewardList } from './src/endpoints'
import { Fetcher } from "./src/fetcher";
config();

import {
checkResp,
getAll,
getByChainAndToken,
getRewardList,
} from "./src/endpoints";

const app = express();
const port = process.env.PORT ?? 8000;
app.use(express.json());
app.use(cors({
origin: '*',
app.use(json());
app.use(
cors({
origin: "*",
credentials: true,
methods: 'GET,PUT,POST,OPTIONS',
allowedHeaders: 'Content-Type,Authorization'
}));
methods: "GET,PUT,POST,OPTIONS",
allowedHeaders: "Content-Type,Authorization",
}),
);

let f = new Fetcher();
(async function run() {
await f.loop();
}());
const f = new Fetcher();
void (async function run() {
await f.loop();
})();

app.get('/api/rewards/all/', (req, res) => {
getAll(req, res, f)
app.get("/api/rewards/all/", (req, res) => {
void getAll(req, res, f);
});
app.get('/api/rewards/:chainId/:tokenAddress', (req, res) => {
getByChainAndToken(req, res, f)
app.get("/api/rewards/:chainId/:tokenAddress", (req, res) => {
void getByChainAndToken(req, res, f);
});
app.post('/api/rewards/list', (req, res) => {
getRewardList(req, res, f)
app.post("/api/rewards/list", (req, res) => {
void getRewardList(req, res, f);
});
app.get('/api/rewards/list', (req, res) => {
checkResp({
status: "error",
description: "Method Not Allowed: use POST"
}, res);
app.get("/api/rewards/list", (req, res) => {
checkResp(
{
status: "error",
description: "Method Not Allowed: use POST",
},
res,
);
});
app.listen(port, () => {
console.log(`[server]: Server is running at http://localhost:${port}`);
console.log(`[server]: Server is running at http://localhost:${port}`);
});


Loading

0 comments on commit f7c414b

Please sign in to comment.