Skip to content

Commit 60dc02b

Browse files
committed
chore: setup code formatter
Refactor code to use single quotes for string literals across the project; update workflows for consistency and add CI configuration with Prettier settings.
1 parent 23e06a5 commit 60dc02b

36 files changed

+354
-366
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
ci:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
25+
- name: Install dependencies
26+
run: npm install
27+
28+
- name: Run CI
29+
run: npm run ci

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"tabWidth": 2
7+
}

.vscode/settings.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
{
2-
"cSpell.words": [
3-
"AREWEAVE",
4-
"Arweave",
5-
"m3ter",
6-
"m3tering"
7-
]
8-
}
2+
"cSpell.words": ["AREWEAVE", "Arweave", "m3ter", "m3tering"]
3+
}

README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,58 @@ Before setting up the project, ensure you have the following installed:
1515

1616
1. **Clone the Repository**:
1717

18-
```bash
19-
git clone <repository-url>
20-
cd m3tering-arweave-gateway-interface
21-
```
18+
```bash
19+
git clone <repository-url>
20+
cd m3tering-arweave-gateway-interface
21+
```
2222

2323
2. **Install Dependencies**:
24-
Install the required dependencies using npm:
24+
Install the required dependencies using npm:
2525

26-
```bash
27-
npm install
28-
```
26+
```bash
27+
npm install
28+
```
2929

3030
3. **Configure Environment Variables**:
31-
Create a `.env` file in the root directory by copying the provided `.env.example` file:
31+
Create a `.env` file in the root directory by copying the provided `.env.example` file:
3232

33-
```bash
34-
cp .env.example .env
35-
```
33+
```bash
34+
cp .env.example .env
35+
```
3636

37-
Update the `.env` file with your Arweave Gateway URL and MongoDB URI:
37+
Update the `.env` file with your Arweave Gateway URL and MongoDB URI:
3838

39-
```env
40-
ARWEAVE_GATEWAY_URL=<your-arweave-gateway-url>
41-
MONGODB_URI=<your-mongodb-uri>
42-
```
39+
```env
40+
ARWEAVE_GATEWAY_URL=<your-arweave-gateway-url>
41+
MONGODB_URI=<your-mongodb-uri>
42+
```
4343

4444
4. **Compile the TypeScript Code**:
45-
Compile the TypeScript code into JavaScript:
45+
Compile the TypeScript code into JavaScript:
4646

47-
```bash
48-
npm run compile
49-
```
47+
```bash
48+
npm run compile
49+
```
5050

5151
5. **Run the Application**:
52-
Start the application:
52+
Start the application:
5353

54-
```bash
55-
npm start
56-
```
54+
```bash
55+
npm start
56+
```
5757

58-
Alternatively, for development with hot-reloading:
58+
Alternatively, for development with hot-reloading:
5959

60-
```bash
61-
npm run dev
62-
```
60+
```bash
61+
npm run dev
62+
```
6363

6464
6. **Access the GraphQL Interface**:
65-
Once the application is running, you can access the GraphQL interface at:
65+
Once the application is running, you can access the GraphQL interface at:
6666

67-
```browser
68-
http://localhost:4001/graphql
69-
```
67+
```browser
68+
http://localhost:4001/graphql
69+
```
7070

7171
## Project Structure
7272

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"scripts": {
66
"compile": "tsc",
77
"start": "npm run compile && node ./dist/index.js",
8-
"dev": "nodemon --watch src --watch . --ext ts,graphql --watch .env"
8+
"dev": "nodemon --watch src --watch . --ext ts,graphql --watch .env",
9+
"format": "prettier --write .",
10+
"check-format": "prettier --check .",
11+
"ci": "npm run build && npm run check-format"
912
},
1013
"keywords": [],
1114
"author": "",
@@ -26,6 +29,7 @@
2629
"devDependencies": {
2730
"@types/node": "^22.14.1",
2831
"nodemon": "^3.1.10",
32+
"prettier": "^3.6.2",
2933
"ts-node": "^10.9.2",
3034
"typescript": "^5.8.3"
3135
}

src/config/arweave.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,41 @@
1-
import { ARWEAVE_GATEWAY_URL, ARWEAVE_PEERS } from "../constants"
1+
import { ARWEAVE_GATEWAY_URL, ARWEAVE_PEERS } from '../constants';
22

33
class ArweaveConfig {
4-
private gatewayUrl: string
4+
private gatewayUrl: string;
55

66
constructor() {
7-
this.gatewayUrl = ARWEAVE_GATEWAY_URL
8-
? ARWEAVE_GATEWAY_URL
9-
: ARWEAVE_PEERS[0]
7+
this.gatewayUrl = ARWEAVE_GATEWAY_URL ? ARWEAVE_GATEWAY_URL : ARWEAVE_PEERS[0];
108

119
if (!this.gatewayUrl) {
12-
throw new Error("No Arweave gateway URL provided")
10+
throw new Error('No Arweave gateway URL provided');
1311
}
1412
}
1513

1614
public getGatewayUrl(): string {
17-
return this.gatewayUrl
15+
return this.gatewayUrl;
1816
}
1917

2018
public rotateGatewayUrl() {
2119
// Rotate to the next gateway URL in the list
22-
const currentURL = this.gatewayUrl
23-
const currentIndex = ARWEAVE_PEERS.indexOf(currentURL)
20+
const currentURL = this.gatewayUrl;
21+
const currentIndex = ARWEAVE_PEERS.indexOf(currentURL);
2422
if (currentIndex === -1 || currentIndex === ARWEAVE_PEERS.length - 1) {
25-
this.gatewayUrl = ARWEAVE_PEERS[0]
23+
this.gatewayUrl = ARWEAVE_PEERS[0];
2624
} else {
27-
this.gatewayUrl = ARWEAVE_PEERS[currentIndex + 1]
25+
this.gatewayUrl = ARWEAVE_PEERS[currentIndex + 1];
2826
}
2927

3028
// if new url is an ip, make sure it is a full url
31-
if (
32-
!this.gatewayUrl.startsWith("http://") &&
33-
!this.gatewayUrl.startsWith("https://")
34-
) {
35-
this.gatewayUrl = `http://${this.gatewayUrl}`
29+
if (!this.gatewayUrl.startsWith('http://') && !this.gatewayUrl.startsWith('https://')) {
30+
this.gatewayUrl = `http://${this.gatewayUrl}`;
3631
}
3732

3833
if (this.gatewayUrl === currentURL && ARWEAVE_PEERS.length > 1) {
39-
this.rotateGatewayUrl()
34+
this.rotateGatewayUrl();
4035
}
4136

42-
return this.gatewayUrl
37+
return this.gatewayUrl;
4338
}
4439
}
4540

46-
export const arweaveConfig = new ArweaveConfig()
41+
export const arweaveConfig = new ArweaveConfig();

src/config/mongo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import mongoose from "mongoose";
2-
import { MONGODB_URI } from "../constants";
1+
import mongoose from 'mongoose';
2+
import { MONGODB_URI } from '../constants';
33

44
export const connectDB = async () => {
55
try {

src/config/server.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import fs from "fs";
2-
import http from "http";
3-
import cors from "cors";
4-
import express from "express";
5-
import logger from "morgan";
6-
import { ApolloServer } from "@apollo/server";
7-
import { expressMiddleware } from "@as-integrations/express5";
8-
import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
9-
import { resolvers as v1Resolvers } from "../resolvers/v1/index";
10-
import { resolvers as v2Resolvers } from "../resolvers/v2/index";
1+
import fs from 'fs';
2+
import http from 'http';
3+
import cors from 'cors';
4+
import express from 'express';
5+
import logger from 'morgan';
6+
import { ApolloServer } from '@apollo/server';
7+
import { expressMiddleware } from '@as-integrations/express5';
8+
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
9+
import { resolvers as v1Resolvers } from '../resolvers/v1/index';
10+
import { resolvers as v2Resolvers } from '../resolvers/v2/index';
1111

1212
// load graphql schema from file
13-
const typeDefsV1 = fs.readFileSync("./schema.graphql", "utf-8");
14-
const typeDefsV2 = fs.readFileSync("./schema.v2.graphql", "utf-8");
13+
const typeDefsV1 = fs.readFileSync('./schema.graphql', 'utf-8');
14+
const typeDefsV2 = fs.readFileSync('./schema.v2.graphql', 'utf-8');
1515

1616
const app = express();
1717
const httpServer = http.createServer(app);
@@ -35,18 +35,18 @@ export async function startServer() {
3535

3636
// configure versioned endpoints
3737
app.use(cors());
38-
app.use(logger("dev"));
39-
app.use("/graphql", express.json(), expressMiddleware(serverV1)); // maintain V1 as default for "/graphql"
40-
app.use("/v1", express.json(), expressMiddleware(serverV1));
41-
app.use("/v1/graphql", express.json(), expressMiddleware(serverV1));
42-
app.use("/v2", express.json(), expressMiddleware(serverV2));
43-
app.use("/v2/graphql", express.json(), expressMiddleware(serverV2));
44-
app.use("/", express.json(), expressMiddleware(serverV1)); // maintain V1 as default for "/graphql"
38+
app.use(logger('dev'));
39+
app.use('/graphql', express.json(), expressMiddleware(serverV1)); // maintain V1 as default for "/graphql"
40+
app.use('/v1', express.json(), expressMiddleware(serverV1));
41+
app.use('/v1/graphql', express.json(), expressMiddleware(serverV1));
42+
app.use('/v2', express.json(), expressMiddleware(serverV2));
43+
app.use('/v2/graphql', express.json(), expressMiddleware(serverV2));
44+
app.use('/', express.json(), expressMiddleware(serverV1)); // maintain V1 as default for "/graphql"
4545

4646
return await new Promise<void>((resolve) => {
4747
const PORT = process.env.PORT || 4000;
4848
httpServer.listen({ port: PORT }, () => {
49-
console.log("Subgraph server started on port", PORT);
49+
console.log('Subgraph server started on port', PORT);
5050
resolve();
5151
});
5252
});

src/config/warp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { WarpFactory } from "warp-contracts";
1+
import { WarpFactory } from 'warp-contracts';
22

33
export const warp = WarpFactory.forMainnet();

0 commit comments

Comments
 (0)