Skip to content

Commit 4dd4fa0

Browse files
committed
Cleanup - remove database and unused exports
1 parent 97fdfc8 commit 4dd4fa0

File tree

10 files changed

+1926
-528
lines changed

10 files changed

+1926
-528
lines changed

.env.sample

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ SMTP_TRANSPORT_REQUIRE_TLS=
3636
# email address which will be the sender of the notifications and email verification messages
3737
EMAIL_SENDER=[email protected]
3838

39-
# Database configuration
40-
DB_DIALECT=sqlite
41-
DB_STORAGE=
42-
DB_DATABASE=
43-
DB_USERNAME=
44-
DB_PASSWORD=
45-
DB_HOST=
46-
DB_PORT=
47-
4839
# JWT
4940
# path to JWT (private) key
5041
# you can use the command `openssl ecparam -name prime256v1 -genkey -noout -out ecdsa-p256-private.pem` to generate one

.eslintrc.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ extends:
44
- eslint:recommended
55
- plugin:@typescript-eslint/recommended
66
- plugin:prettier/recommended
7+
- plugin:import/recommended
8+
- plugin:import/typescript
9+
settings:
10+
import/parsers:
11+
'@typescript-eslint/parser':
12+
- .ts
13+
import/resolver:
14+
typescript:
15+
alwaysTryTypes: true
16+
node: true
17+
718
parser: '@typescript-eslint/parser'
819
parserOptions:
920
ecmaVersion: 9
@@ -17,3 +28,6 @@ rules:
1728
- args: after-used
1829
ignoreRestSiblings: false
1930
'no-console': 'warn'
31+
import/no-unused-modules:
32+
- warn
33+
- unusedExports: true

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@
3131
"@types/sinon": "^10.0.15",
3232
"@types/tough-cookie": "^4.0.5",
3333
"@typescript-eslint/eslint-plugin": "^6.0.0",
34-
"@typescript-eslint/parser": "^6.0.0",
34+
"@typescript-eslint/parser": "^6.19.0",
3535
"chai": "^4.3.7",
3636
"cheerio": "^1.0.0-rc.12",
3737
"eslint": "^8.13.0",
3838
"eslint-config-prettier": "^8.5.0",
39+
"eslint-import-resolver-typescript": "^3.6.1",
40+
"eslint-plugin-import": "^2.29.1",
3941
"eslint-plugin-prettier": "^5.0.0",
42+
"install": "^0.13.0",
4043
"maildev": "^2.1.0",
4144
"mocha": "^10.2.0",
4245
"msw": "^2.0.14",
46+
"npm": "^10.3.0",
4347
"prettier": "^3.0.0",
4448
"rdf-namespaces": "^1.11.0",
4549
"sinon": "^15.2.0",
@@ -69,8 +73,6 @@
6973
"lodash": "^4.17.21",
7074
"n3": "^1.17.0",
7175
"nodemailer": "^6.9.4",
72-
"parse-link-header": "^2.0.0",
73-
"sequelize": "^6.32.1",
74-
"sqlite3": "^5.1.6"
76+
"parse-link-header": "^2.0.0"
7577
}
7678
}

src/config/index.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dotenv/config'
22
import SMTPTransport from 'nodemailer/lib/smtp-transport'
3-
import { Dialect, Options } from 'sequelize'
43

54
// the defaults work for tests. you should define your own
65
// either via .env file, or via environment variables directly (depends on your setup)
@@ -47,17 +46,6 @@ export const port: number = +(process.env.PORT ?? 3005)
4746
// email verification expiration in seconds (1 hour)
4847
export const emailVerificationExpiration = 3600
4948

50-
// configuration of database in form of sequelize options
51-
export const database: Options = {
52-
dialect: (process.env.DB_DIALECT as Dialect) ?? 'sqlite',
53-
storage: process.env.DB_STORAGE || undefined, // Path to the SQLite database file (default is memory)
54-
database: process.env.DB_DATABASE || undefined,
55-
username: process.env.DB_USERNAME || undefined,
56-
password: process.env.DB_PASSWORD || undefined,
57-
host: process.env.DB_HOST || undefined,
58-
port: process.env.DB_PORT ? +process.env.DB_PORT : undefined,
59-
}
60-
6149
export const isBehindProxy = stringToBoolean(process.env.BEHIND_PROXY)
6250

6351
const stringToArray = (value: string | undefined) => {

src/config/sequelize.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/controllers/integration.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { readFile } from 'fs-extra'
2-
import jsonwebtoken, {
3-
JsonWebTokenError,
4-
TokenExpiredError,
5-
} from 'jsonwebtoken'
2+
import * as jsonwebtoken from 'jsonwebtoken'
3+
import { JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken'
64
import { Middleware } from 'koa'
75
import { pick } from 'lodash'
86
import * as config from '../config'

src/test/helpers/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai'
22
import * as cheerio from 'cheerio'
33
import { createAccount } from 'css-authn/dist/7.x'
44
import { createSandbox } from 'sinon'
5-
import * as uuid from 'uuid'
5+
import { v4 as uuidv4 } from 'uuid'
66
import * as config from '../../config'
77
import * as mailerService from '../../services/mailerService'
88

@@ -12,9 +12,9 @@ export const createRandomAccount = ({
1212
solidServer: string
1313
}) => {
1414
return createAccount({
15-
username: uuid.v4(),
16-
password: uuid.v4(),
17-
email: uuid.v4() + '@example.com',
15+
username: uuidv4(),
16+
password: uuidv4(),
17+
email: uuidv4() + '@example.com',
1818
provider: solidServer,
1919
})
2020
}
@@ -45,7 +45,7 @@ export const initIntegration = async ({
4545
return { verificationLink }
4646
}
4747

48-
export const finishIntegration = async (verificationLink: string) => {
48+
const finishIntegration = async (verificationLink: string) => {
4949
const response = await fetch(verificationLink)
5050
expect(response.ok).to.be.true
5151
const jwt = await response.text()

src/test/helpers/setupPod.ts

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from 'chai'
2-
import { foaf, ldp, solid, space } from 'rdf-namespaces'
2+
import { foaf, solid, space } from 'rdf-namespaces'
33
import * as config from '../../config'
44
import { Person } from './types'
55

@@ -124,68 +124,12 @@ export const setupEmailSettings = async ({
124124
})
125125
}
126126

127-
export const setupInbox = async ({
128-
webId,
129-
inbox,
130-
authenticatedFetch,
131-
}: {
132-
webId: string
133-
inbox: string
134-
authenticatedFetch: typeof fetch
135-
}) => {
136-
// create inbox
137-
const createInboxResponse = await authenticatedFetch(inbox, {
138-
method: 'PUT',
139-
headers: {
140-
link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',
141-
'content-type': 'text/turtle',
142-
},
143-
})
144-
145-
expect(createInboxResponse.ok).to.be.true
146-
147-
const createInboxAclResponse = await authenticatedFetch(inbox + '.acl', {
148-
// this .acl is a shortcut, should find .acl properly TODO
149-
method: 'PUT',
150-
headers: { 'content-type': 'text/turtle' },
151-
body: `
152-
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
153-
154-
<#Append>
155-
a acl:Authorization;
156-
acl:agentClass acl:AuthenticatedAgent;
157-
acl:accessTo <./>;
158-
acl:default <./>;
159-
acl:mode acl:Append.
160-
<#ControlReadWrite>
161-
a acl:Authorization;
162-
acl:agent <${webId}>;
163-
acl:accessTo <./>;
164-
acl:default <./>;
165-
acl:mode acl:Control, acl:Read, acl:Write.
166-
`,
167-
})
168-
169-
expect(createInboxAclResponse.ok).to.be.true
170-
171-
const linkInboxResponse = await authenticatedFetch(webId, {
172-
method: 'PATCH',
173-
headers: { 'content-type': 'text/n3' },
174-
body: `
175-
_:mutate a <${solid.InsertDeletePatch}>; <${solid.inserts}> {
176-
<${webId}> <${ldp.inbox}> <${inbox}>.
177-
}.`,
178-
})
179-
180-
expect(linkInboxResponse.ok).to.be.true
181-
}
182-
183127
/**
184128
* Give agent a read access (e.g. to inbox)
185129
*
186130
* Currently assumes we're changing rights to container!
187131
*/
188-
export const addRead = async ({
132+
const addRead = async ({
189133
resource,
190134
agent,
191135
authenticatedFetch,
@@ -215,7 +159,7 @@ export const addRead = async ({
215159
return response
216160
}
217161

218-
export const addPublicRead = async ({
162+
const addPublicRead = async ({
219163
resource,
220164
authenticatedFetch,
221165
}: {

src/test/testSetup.spec.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { HttpResponse, http } from 'msw'
77
import { SetupServer, setupServer } from 'msw/node'
88
import app from '../app'
99
import { port } from '../config'
10-
import { EmailVerification, Integration } from '../config/sequelize'
1110
import { createRandomAccount } from './helpers'
1211
import type { Person } from './helpers/types'
1312

@@ -74,12 +73,6 @@ after(done => {
7473
maildev.close(done)
7574
})
7675

77-
// clear the database before each test
78-
beforeEach(async () => {
79-
await EmailVerification.destroy({ truncate: true })
80-
await Integration.destroy({ truncate: true })
81-
})
82-
8376
/**
8477
* Before each test, create a new account and authenticate to it
8578
*/
@@ -133,10 +126,8 @@ afterEach(() => {
133126
export {
134127
authenticatedFetch,
135128
authenticatedFetch3,
136-
cssServer,
137129
otherAuthenticatedFetch,
138130
otherPerson,
139131
person,
140132
person3,
141-
server,
142133
}

0 commit comments

Comments
 (0)