Skip to content

Commit 6467148

Browse files
mfw78kostysh
authored andcommitted
fix: 🐛 lint
1 parent 3d87ef9 commit 6467148

File tree

6 files changed

+71
-85
lines changed

6 files changed

+71
-85
lines changed

.eslintrc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
{
22
"root": true,
33
"parser": "@typescript-eslint/parser",
4-
"plugins": [
5-
"@typescript-eslint"
6-
],
4+
"plugins": ["@typescript-eslint"],
75
"extends": [
86
"eslint:recommended",
97
"plugin:@typescript-eslint/eslint-recommended",
108
"plugin:@typescript-eslint/recommended"
119
],
12-
"ignorePatterns": [
13-
"dist",
14-
"src/proto"
15-
],
10+
"ignorePatterns": ["dist", "src/proto"],
1611
"rules": {
1712
"@typescript-eslint/no-unused-vars": [
1813
"warn",

README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ How to add observer on waku:
88

99
```typescript
1010
import WakuService from './services/WakuService';
11-
import { Test } from "./proto/test";
11+
import { Test } from './proto/test';
1212
import WakuService, { WakuMessageHandler } from './services/WakuService';
1313

14-
const wakuService = await WakuService
15-
.getInstance()
16-
.connect()
17-
;
18-
14+
const wakuService = await WakuService.getInstance().connect();
1915
const handler: WakuMessageHandler = (message) => {
2016
return wakuService.processMessage(Test, message);
2117
};
@@ -24,11 +20,7 @@ await wakuService.makeWakuObserver(handler, ['some-topic']);
2420
```
2521

2622
```typescript
27-
const wakuService = await WakuService
28-
.getInstance()
29-
.connect()
30-
;
31-
23+
const wakuService = await WakuService.getInstance().connect();
3224
const testPayload: Test = {
3325
test1: 'some-message',
3426
test2: 'some-message 2'

docs/STORAGE.md

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ All fields, except simple arrays of a primitives (ie. `number`, `number[]` etc),
1010

1111
Related: [story: AP reservation overview](https://github.com/windingtree/win-stays/issues/17)
1212

13-
Identify what *queries* must be able to be answered from the database:
13+
Identify what _queries_ must be able to be answered from the database:
1414

1515
1. How to get information relating to a booking?
1616
2. How to get what bookings are staying at an accommodation facility on a specific day?
@@ -30,7 +30,7 @@ Description: A list of facilities that are handled by this `lpms-server`.
3030

3131
### facilities
3232

33-
Parent level: *root*
33+
Parent level: _root_
3434
Level: `facilityId` (dynamic)
3535

3636
Key: `metadata`
@@ -174,7 +174,7 @@ Level: `stubs`
174174

175175
Key: `YYYY-MM-DD` (dynamic)
176176
Value: `string[]`
177-
Description: Contains a list of all stubs, ie. `stubId` (bookings) that are on the date YYYY-MM-DD in this `spaceId`.
177+
Description: Contains a list of all stubs, ie. `stubId` (bookings) that are on the date YYYY-MM-DD in this `spaceId`.
178178
Notes: This meets the requirement (3)
179179

180180
Key: `YYYY-MM-DD-num_booked` (dynamic)
@@ -210,25 +210,27 @@ Description: Contains generic data for the item (name, photos, etc)
210210
4. Find number of spaces (rooms) booked by date: `facilityId.spaceId.stubs.YYYY-MM-DD-num_booked`.
211211
5. Determine if a space can be booked on a given day:
212212

213-
With daily availability override:
213+
With daily availability override:
214214

215-
`Ask.numSpacesReq <= (facilityId.spaceId.availability.YYYY-MM-DD - facilityId.spaceId.YYYY-MM-DD-num_booked)`
215+
`Ask.numSpacesReq <= (facilityId.spaceId.availability.YYYY-MM-DD - facilityId.spaceId.YYYY-MM-DD-num_booked)`
216216

217-
With no daily availability override:
217+
With no daily availability override:
218218

219-
`Ask.numSpacesReq <= (facilityId.spaceId.availability.default - facilityId.spaceId.YYYY-MM-DD-num_booked)`
219+
`Ask.numSpacesReq <= (facilityId.spaceId.availability.default - facilityId.spaceId.YYYY-MM-DD-num_booked)`
220+
221+
This meets the requirement of (5)
220222

221-
This meets the requirement of (5)
222223
6. Determine if a space can be booked for a date range:
223224

224-
```python
225-
for day in date_range:
226-
# isAvailable = logic from (5) above
227-
if (!isAvailable)
228-
return false
229-
return true
230-
```
231-
This meets the requirement of (6)
225+
```python
226+
for day in date_range:
227+
# isAvailable = logic from (5) above
228+
if (!isAvailable)
229+
return false
230+
return true
231+
```
232+
233+
This meets the requirement of (6)
232234

233235
### Update
234236

@@ -243,40 +245,39 @@ Description: Contains generic data for the item (name, photos, etc)
243245
In order to generate the final `metadata` binary glob that is uploaded to `IPFS`:
244246

245247
```typescript
246-
247-
let items: ServiceItemData[]
248+
let items: ServiceItemData[];
248249

249250
// process all spaces
250-
const spaces = db.get('facilityId.spaces') // insert correct leveldb query here
251+
const spaces = db.get('facilityId.spaces'); // insert correct leveldb query here
251252
for (const space of object) {
252-
// get generic metadata
253-
const generic = db.get(`${facilityId}.${space}.metadata_generic`) as Item
254-
const specific = db.get(`${facilityId}.${space}.metadata`) as Space
255-
generic.payload = Space.toBinary(specific)
256-
257-
items.push({
258-
item: utils.arrayify(utils.formatBytes32String(space)),
259-
payload: Item.toBinary(generic)
260-
})
253+
// get generic metadata
254+
const generic = db.get(`${facilityId}.${space}.metadata_generic`) as Item;
255+
const specific = db.get(`${facilityId}.${space}.metadata`) as Space;
256+
generic.payload = Space.toBinary(specific);
257+
258+
items.push({
259+
item: utils.arrayify(utils.formatBytes32String(space)),
260+
payload: Item.toBinary(generic)
261+
});
261262
}
262263

263264
// process all other items
264-
const otherItems = db.get('facilityId.otherItems') as Item[]
265+
const otherItems = db.get('facilityId.otherItems') as Item[];
265266
for (const item of otherItems) {
266-
const otherItem = db.get(`${facilityId}.otherItems.${item}`) as Item
267-
items.push({
268-
item: utils.arrayify(utils.formatBytes32String(item)),
269-
payload: Item.toBinary(otherItem)
270-
})
267+
const otherItem = db.get(`${facilityId}.otherItems.${item}`) as Item;
268+
items.push({
269+
item: utils.arrayify(utils.formatBytes32String(item)),
270+
payload: Item.toBinary(otherItem)
271+
});
271272
}
272273

273274
// assemble the metadata for signing / publishing
274275
const serviceProviderData: ServiceProviderData = {
275-
serviceProvider: utils.arrayify(utils.formatBytes32String('provider')),
276-
payload: Facility.toBinary(db.get(`$facilityId.metadata`)),
277-
items: items,
278-
terms: []
279-
}
276+
serviceProvider: utils.arrayify(utils.formatBytes32String('provider')),
277+
payload: Facility.toBinary(db.get(`$facilityId.metadata`)),
278+
items: items,
279+
terms: []
280+
};
280281
```
281282

282283
# Todo

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"prepublish": "yarn typechain:videre && yarn protoc:libs && yarn protoc:local",
2626
"dev": "cross-env NODE_ENV=development nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec 'ts-node' src/index.ts",
2727
"lint": "npx eslint . --ext .ts",
28-
"lint:fix": "npx eslint . --ext .ts --fix",
28+
"lint:fix": "npx eslint . --ext .ts --fix && npx prettier --write .",
2929
"test": "npx mocha -r ts-node/register test/**/*.spec.ts",
3030
"clean": "rm -rf dist",
3131
"build": "yarn clean && yarn tsc -p tsconfig-build.json",

swagger/server.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
import express, { Application } from "express";
2-
import morgan from "morgan";
3-
import swaggerUI from "swagger-ui-express";
4-
import swaggerJsDoc from "swagger-jsdoc";
5-
import { options } from "./swagger-options";
1+
import express, { Application } from 'express';
2+
import morgan from 'morgan';
3+
import swaggerUI from 'swagger-ui-express';
4+
import swaggerJsDoc from 'swagger-jsdoc';
5+
import { options } from './swagger-options';
66

7-
import Router from "../src/router";
7+
import Router from '../src/router';
88

99
const PORT = process.env.SWAGGER_PORT || 3000;
1010

1111
const app: Application = express();
1212

1313
app.use(express.json());
14-
app.use(morgan("tiny"));
15-
app.use(express.static("public"));
14+
app.use(morgan('tiny'));
15+
app.use(express.static('public'));
1616

1717
const specs = swaggerJsDoc(options);
1818

19-
app.use(
20-
"/docs",
21-
swaggerUI.serve,
22-
swaggerUI.setup(specs)
23-
);
19+
app.use('/docs', swaggerUI.serve, swaggerUI.setup(specs));
2420

2521
app.use(Router);
2622

2723
app.listen(PORT, () => {
28-
console.log("Server is running on port", PORT);
24+
console.log('Server is running on port', PORT);
2925
});

swagger/swagger-options.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
export const options = {
22
definition: {
3-
openapi: "3.0.3",
3+
openapi: '3.0.3',
44
info: {
5-
title: "API",
6-
version: "1.0.0",
7-
description: "",
5+
title: 'API',
6+
version: '1.0.0',
7+
description: ''
88
},
99
components: {
1010
securitySchemes: {
1111
bearerAuth: {
1212
type: 'http',
1313
scheme: 'bearer',
14-
bearerFormat: 'JWT',
14+
bearerFormat: 'JWT'
1515
}
1616
}
1717
},
18-
security: [{
19-
bearerAuth: []
20-
}],
21-
servers: [
18+
security: [
2219
{
23-
url: "http://localhost:5000/api",
24-
description: "local server"
25-
},
20+
bearerAuth: []
21+
}
2622
],
23+
servers: [
24+
{
25+
url: 'http://localhost:5000/api',
26+
description: 'local server'
27+
}
28+
]
2729
},
28-
apis: ["./src/router/*.ts"],
30+
apis: ['./src/router/*.ts']
2931
};

0 commit comments

Comments
 (0)