Skip to content

Commit 0466c5b

Browse files
committed
chore: linter
1 parent ef9807f commit 0466c5b

File tree

7 files changed

+55
-60
lines changed

7 files changed

+55
-60
lines changed

packages/streams/nmea0183-signalk.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ function Nmea0183ToSignalK(options) {
3939
Transform.call(this, {
4040
objectMode: true,
4141
})
42-
this.debug = (options.createDebug || require('debug'))('signalk:streams:nmea0183-signalk')
43-
42+
this.debug = (options.createDebug || require('debug'))(
43+
'signalk:streams:nmea0183-signalk'
44+
)
4445

4546
this.parser = new Parser(options)
4647
this.n2kParser = new FromPgn(options)

src/api/course/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import Debug from 'debug'
2-
const debug = Debug('signalk:courseApi')
3-
// import { createDebug } from './debug'
4-
// const debug = createDebug('signalk:courseApi')
1+
import { createDebug } from '../../debug'
2+
const debug = createDebug('signalk:courseApi')
3+
54
import { FullSignalK } from '@signalk/signalk-schema'
65
import { Application, Request, Response } from 'express'
76
import _ from 'lodash'
@@ -10,9 +9,9 @@ import { WithConfig } from '../../app'
109
import { WithSecurityStrategy } from '../../security'
1110
import { Position } from '../../types'
1211

12+
import { Responses } from '../'
1313
import { Store } from '../../serverstate/store'
1414
import { Route } from '../resources/types'
15-
import { Responses } from '../'
1615

1716
const SIGNALK_API_PATH = `/signalk/v1/api`
1817
const COURSE_API_PATH = `${SIGNALK_API_PATH}/vessels/self/navigation/course`

src/api/index.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
export interface ApiResponse {
2-
state: 'FAILED' | 'COMPLETED' | 'PENDING'
3-
statusCode: number
4-
message: string
5-
requestId?: string
6-
href?: string
7-
token?: string
2+
state: 'FAILED' | 'COMPLETED' | 'PENDING'
3+
statusCode: number
4+
message: string
5+
requestId?: string
6+
href?: string
7+
token?: string
88
}
99

1010
export const Responses = {
11-
ok: {
12-
state: 'COMPLETED',
13-
statusCode: 200,
14-
message: 'OK'
15-
},
16-
invalid: {
17-
state: 'FAILED',
18-
statusCode: 406,
19-
message: `Invalid Data supplied.`
20-
},
21-
unauthorised: {
22-
state: 'FAILED',
23-
statusCode: 403,
24-
message: 'Unauthorised'
25-
},
26-
notFound: {
27-
state: 'FAILED',
28-
statusCode: 404,
29-
message: 'Resource not found.'
30-
}
11+
ok: {
12+
state: 'COMPLETED',
13+
statusCode: 200,
14+
message: 'OK'
15+
},
16+
invalid: {
17+
state: 'FAILED',
18+
statusCode: 406,
19+
message: `Invalid Data supplied.`
20+
},
21+
unauthorised: {
22+
state: 'FAILED',
23+
statusCode: 403,
24+
message: 'Unauthorised'
25+
},
26+
notFound: {
27+
state: 'FAILED',
28+
statusCode: 404,
29+
message: 'Resource not found.'
30+
}
3131
}
3232

3333
// returns true if target path is an API request
34-
export function isApiRequest(path:string): boolean {
35-
if (
36-
path.split('/')[4] === 'resources' || // resources API
37-
path.indexOf('/navigation/course/') !== -1 // course API
38-
) {
39-
return true
40-
} else {
41-
return false
42-
}
43-
}
34+
export function isApiRequest(path: string): boolean {
35+
if (
36+
path.split('/')[4] === 'resources' || // resources API
37+
path.indexOf('/navigation/course/') !== -1 // course API
38+
) {
39+
return true
40+
} else {
41+
return false
42+
}
43+
}

src/api/resources/index.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import Debug from 'debug'
2-
const debug = Debug('signalk:resourcesApi')
3-
// import { createDebug } from './debug'
4-
// const debug = createDebug('signalk:resourcesApi')
1+
import { createDebug } from '../../debug'
2+
const debug = createDebug('signalk:resourcesApi')
53

64
import {
75
ResourceProvider,
@@ -11,7 +9,7 @@ import {
119

1210
import { Application, NextFunction, Request, Response } from 'express'
1311
import { v4 as uuidv4 } from 'uuid'
14-
//import { SignalKMessageHub } from '../../app'
12+
// import { SignalKMessageHub } from '../../app'
1513
import { WithSecurityStrategy } from '../../security'
1614

1715
import { Responses } from '../'
@@ -21,13 +19,11 @@ import { validate } from './validate'
2119
const SIGNALK_API_PATH = `/signalk/v1/api`
2220
const UUID_PREFIX = 'urn:mrn:signalk:uuid:'
2321

24-
interface ResourceApplication
25-
extends Application,
26-
WithSecurityStrategy {
27-
handleMessage: (id: string, data: any) => void
28-
}
22+
interface ResourceApplication extends Application, WithSecurityStrategy {
23+
handleMessage: (id: string, data: any) => void
24+
}
2925

30-
export class Resources {
26+
export class ResourcesApi {
3127
private resProvider: { [key: string]: ResourceProviderMethods | null } = {}
3228
private server: ResourceApplication
3329

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import SubscriptionManager from './subscriptionmanager'
4646
import { Delta } from './types'
4747

4848
import { CourseApi } from './api/course'
49-
import { Resources } from './api/resources'
49+
import { ResourcesApi } from './api/resources'
5050

5151
const debug = createDebug('signalk-server')
5252

@@ -80,7 +80,7 @@ class Server {
8080
require('./serverroutes')(app, saveSecurityConfig, getSecurityConfig)
8181
require('./put').start(app)
8282

83-
app.resourcesApi = new Resources(app)
83+
app.resourcesApi = new ResourcesApi(app)
8484
const courseApi = new CourseApi(app)
8585

8686
app.signalk = new FullSignalK(app.selfId, app.selfType)

src/put.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { v4: uuidv4 } = require('uuid')
55
const { createRequest, updateRequest } = require('./requestResponse')
66
const skConfig = require('./config/config')
77

8-
const {isApiRequest} = require('./api')
8+
const { isApiRequest } = require('./api')
99

1010
const pathPrefix = '/signalk'
1111
const versionPrefix = '/v1'
@@ -33,13 +33,12 @@ module.exports = {
3333
app.deRegisterActionHandler = deRegisterActionHandler
3434

3535
app.put(apiPathPrefix + '*', function(req, res, next) {
36-
3736
// check for resources API, course API, etc request
3837
if (isApiRequest(req.path)) {
3938
next()
4039
return
4140
}
42-
41+
4342
let path = String(req.path).replace(apiPathPrefix, '')
4443

4544
const value = req.body

src/security.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { Request } from 'express'
1718
import {
1819
chmodSync,
1920
existsSync,
@@ -30,7 +31,6 @@ import { Mode } from 'stat-mode'
3031
import { WithConfig } from './app'
3132
import { createDebug } from './debug'
3233
import dummysecurity from './dummysecurity'
33-
import { Request } from 'express'
3434
const debug = createDebug('signalk-server:security')
3535

3636
export interface WithSecurityStrategy {

0 commit comments

Comments
 (0)