-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* referencing schemas * updated search schema * articles updated * collections * refactored schemas used in public services, added validation * deleted unused files * updated collectable items * removed unused schemas * added still used schema * generated types
- Loading branch information
Showing
62 changed files
with
1,745 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
const { execSync } = require('node:child_process') | ||
const fs = require('node:fs') | ||
|
||
const basePath = './src/services' | ||
const basePath = './src/schema' | ||
|
||
// for now support only the followin services until we migrate everything: | ||
const supportedServices = ['text-reuse-clusters'] | ||
const schemaBits = ['schemas', 'parameters', 'requestBodies', 'responses'] | ||
|
||
const directories = fs | ||
.readdirSync('./src/services') | ||
.readdirSync(basePath) | ||
.filter(item => { | ||
return fs.statSync(`${basePath}/${item}`).isDirectory() | ||
}) | ||
.filter(item => supportedServices.includes(item)) | ||
.filter(item => schemaBits.includes(item)) | ||
|
||
directories.forEach(service => { | ||
directories.forEach(dir => { | ||
// eslint-disable-next-line no-console | ||
console.log(`Generating types for service ${service}...`) | ||
console.log(`Generating types for service ${dir}...`) | ||
const command = | ||
`quicktype --src-lang schema --src ${basePath}/${service}/schema/**/*.json` + | ||
` --out ${basePath}/${service}/models/generated.ts --lang ts --just-types` | ||
`quicktype --src-lang schema --src ${basePath}/${dir}/*.json` + | ||
` --out ./src/models/generated/${dir}.ts --lang ts --just-types` | ||
execSync(command) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { OpenAPIV3 } from 'express-openapi-validator/dist/framework/types' | ||
import RefParser, { FileInfo } from '@apidevtools/json-schema-ref-parser' | ||
import type { ImpressoApplication } from '../types' | ||
import type { Application } from '@feathersjs/express' | ||
import * as OpenApiValidator from 'express-openapi-validator' | ||
import fs from 'fs' | ||
|
||
export default async (app: ImpressoApplication & Application) => { | ||
const isPublicApi = app.get('isPublicApi') | ||
if (!isPublicApi) return | ||
|
||
if (!('docs' in app)) throw new Error('`docs` property not found in app object. Is swagger initialized?') | ||
const spec = (app as any)['docs'] as unknown as OpenAPIV3.Document | ||
|
||
const dereferencedOpenApiSpec = await RefParser.dereference(spec, { | ||
resolve: { | ||
file: { | ||
/** | ||
* All JSON schema files are relative to the | ||
* `src` / `dist` directory. Adding it here. | ||
*/ | ||
read: (file: FileInfo) => { | ||
const cwd = process.cwd() | ||
const filePath = file.url.replace(cwd, `${cwd}/dist`) | ||
return fs.readFileSync(filePath, 'utf-8') | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const middlewares = OpenApiValidator.middleware({ | ||
apiSpec: dereferencedOpenApiSpec as unknown as OpenAPIV3.Document, | ||
validateRequests: true, // (default) | ||
validateResponses: true, // false by default | ||
validateApiSpec: false, | ||
}) | ||
middlewares.forEach(middleware => app.use(middleware)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Add-ons for text reuse passages find method. | ||
*/ | ||
export interface Parameters { | ||
newspaper?: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export interface AuthenticationCreateRequest { | ||
email: string; | ||
password: string; | ||
strategy: Strategy; | ||
} | ||
|
||
export enum Strategy { | ||
Local = "local", | ||
} | ||
|
||
export interface NewCollection { | ||
description?: string; | ||
name: string; | ||
status?: string; | ||
} |
Oops, something went wrong.