This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
311 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,6 @@ All **HospitalRun** code lives in a single repository, an architecture generally | |
|
||
We recommend the use of [**nvm**](https://github.com/nvm-sh/nvm#install--update-script) for the management of different versions of Node. | ||
|
||
#### pnpm | ||
Fast, disk space efficient package manager | ||
`npm i -g pnpm` | ||
|
||
#### yarn | ||
Fast, reliable, and secure dependency management. | ||
`npm i -g yarn` | ||
|
@@ -27,8 +23,9 @@ Fast, reliable, and secure dependency management. | |
``` | ||
git clone [email protected]:HospitalRun/hospitalrun.git | ||
git submodule update --init --recursive | ||
npx pnpm install -r --filter @hospitalrun-org/cli | ||
npx pnpm install -r | ||
yarn | ||
yarn workspaces run build | ||
yarn upgrade | ||
# Do some coding then commit with | ||
npx git-cz | ||
# Test the cli | ||
|
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 |
---|---|---|
|
@@ -6,13 +6,26 @@ | |
"author": "Maksim Sink <[email protected]>", | ||
"license": "MIT", | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"nohoist": [ | ||
"**/cz-emoji", | ||
"**/cz-emoji/**", | ||
"**/husky", | ||
"**/husky/**" | ||
] | ||
}, | ||
"scripts": { | ||
"test": "exit 0", | ||
"clean": "rimraf packages/*/node_modules packages/*/dist packages/*/build node_modules", | ||
"download": "wget http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.8/swagger-codegen-cli-2.4.8.jar -d ./bin/", | ||
"build:core": "npm run download && npm run build:swagger && java -Dmodels -jar ./bin/swagger-codegen-cli-2.4.8.jar generate -i ./build/swagger.yml -l typescript-inversify -o ./packages/core", | ||
"download": "mkdirp bin && wget http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.8/swagger-codegen-cli-2.4.8.jar -d ./bin/", | ||
"build:core": "npm run build:core-services && npm run build:core-models", | ||
"build:swagger": "mkdirp ./build && swagger-merger -i ./spec/next/index.yml -o ./build/swagger.yml", | ||
"build:fastify": "npm run build:swagger && snc -t ./templates/fastify -o ./packages/server ./build/swagger.yml" | ||
"build:fastify": "npm run build:swagger && snc -t ./templates/fastify -o ./packages/server/src ./build/swagger.yml", | ||
"build:core-services": "rimraf ./packages/core/src/index.ts && npm run build:swagger && snc -t ./templates/inversify -o ./packages/core/src ./build/swagger.yml", | ||
"build:core-models": "npm run download && npm run build:swagger && java -Dmodels -jar ./bin/swagger-codegen-cli-2.4.8.jar generate -i ./build/swagger.yml -l typescript-inversify -o ./packages/core/src" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.1.0", | ||
|
@@ -26,6 +39,7 @@ | |
"cz-emoji": "^1.1.2", | ||
"dateformat": "^3.0.3", | ||
"husky": "^3.0.5", | ||
"jest": "24.8.0", | ||
"mkdirp": "^0.5.1", | ||
"node-wget": "^0.4.3", | ||
"pnpm": "^3.8.1", | ||
|
Submodule cli
updated
from 78f6cf to 40694d
Submodule core
updated
6 files
+1 −0 | .gitignore | |
+12 −2 | package.json | |
+0 −0 | src/model/.gitkeep | |
+9 −0 | src/service.d.ts | |
+0 −0 | src/service/.gitkeep | |
+29 −0 | tsconfig.json |
Submodule docs
updated
from 57243e to a35050
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
swagger: '2.0' | ||
info: | ||
version: 2.0.0 | ||
title: HospitalRun | ||
description: +HospitalRun API | ||
license: | ||
name: MIT | ||
host: app.hospitalrun.io | ||
basePath: "/next" | ||
securityDefinitions: | ||
couchBasicAuth: | ||
type: basic | ||
couchCookieAuth: | ||
type: apiKey | ||
name: Cookie | ||
in: header | ||
couchProxyAuth: | ||
type: apiKey | ||
name: X-Auth-CouchDB-Token | ||
in: header | ||
couchProxyAuthRoles: | ||
type: apiKey | ||
name: X-Auth-CouchDB-Roles | ||
in: header | ||
couchProxyAuthUsername: | ||
type: apiKey | ||
name: X-Auth-CouchDB-UserName | ||
in: header | ||
|
||
security: | ||
- couchBasicAuth: [] | ||
- couchCookieAuth: [] | ||
- couchProxyAuth: [] | ||
- couchProxyAuthRoles: [] | ||
- couchProxyAuthUsername: [] | ||
|
||
schemes: | ||
- https | ||
consumes: | ||
- application/json | ||
produces: | ||
- application/json | ||
parameters: | ||
$ref#Parameters: "./parameters.yml" | ||
paths: | ||
$ref#UsersMethods: "./users/methods.yml" | ||
definitions: | ||
$ref#UsersModels: "./users/models.yml" |
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 @@ | ||
id: | ||
in: path | ||
name: id | ||
type: string | ||
required: true | ||
description: ID of an Document to Get |
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,14 +1,28 @@ | ||
/users: | ||
/user: | ||
get: | ||
tags: | ||
- Users | ||
operationId: findUsers | ||
- User | ||
operationId: findUser | ||
summary: Finds a User | ||
description: Search for a User in the Database | ||
responses: | ||
"200": | ||
description: Returns a list of Users | ||
description: Returns a User | ||
schema: | ||
type: array | ||
items: | ||
$ref: "#/definitions/User" | ||
$ref: "#/definitions/User" | ||
/user/{id}: | ||
get: | ||
security: | ||
- couchBasicAuth: [] | ||
tags: | ||
- User | ||
operationId: findUserById | ||
summary: Finds a User | ||
parameters: | ||
- $ref: '#/parameters/id' | ||
description: Search for a User in the Database | ||
responses: | ||
"200": | ||
description: Returns a User | ||
schema: | ||
$ref: "#/definitions/User" |
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 |
---|---|---|
|
@@ -5,5 +5,7 @@ User: | |
type: string | ||
last_name: | ||
type: string | ||
username: | ||
type: string | ||
id: | ||
type: string | ||
required: | ||
- id |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import fp from 'fastify-plugin' | ||
import { {{capitalize operation_name}}Service, {{capitalize operation_name}} } from '@hospitalrun-org/core' | ||
|
||
export default fp((fastify, opts, next) => { | ||
const {{camelCase operation_name}}Service = new {{capitalize operation_name}}Service(opts) | ||
{{#each operation}} | ||
{{#each this.path}} | ||
{{#validMethod @key}} | ||
/** | ||
* @param {Object} options | ||
{{#each ../parameters}} | ||
{{#if this.name}} | ||
* @param {{../../../../openbrace}}{{capitalize type}}{{../../../../closebrace}} options.{{name}} {{inline description}} | ||
{{/if}} | ||
{{/each}} | ||
* @throws {Error} | ||
* @return {Promise} | ||
*/ | ||
fastify.decorate('{{../operationId}}', ({{camelCase ../../../operation_name}}: {{capitalize ../../../operation_name}}) => { | ||
return {{camelCase ../../../operation_name}}Service.{{../operationId}}({{camelCase ../../../operation_name}}) | ||
}) | ||
{{/validMethod}} | ||
{{/each}} | ||
{{/each}} | ||
next() | ||
}) | ||
|
||
declare module 'fastify' { | ||
interface FastifyInstance { | ||
{{#each operation}} | ||
{{#each this.path}} | ||
{{#validMethod @key}} | ||
{{../operationId}}(): {{capitalize ../../../operation_name}} | ||
{{/validMethod}} | ||
{{/each}} | ||
{{/each}} | ||
} | ||
} |
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,111 @@ | ||
import { Server, IncomingMessage, ServerResponse } from 'http' | ||
import { FastifyInstance } from 'fastify' | ||
import { nextCallback } from 'fastify-plugin' | ||
|
||
export default( | ||
fastify: FastifyInstance<Server, IncomingMessage, ServerResponse>, | ||
opts: {}, | ||
next: nextCallback, | ||
) => { | ||
{{#each headOperation}} | ||
{{#each this.path}} | ||
{{#validMethod @key}} | ||
/** | ||
{{#each ../descriptionLines}} | ||
* {{{this}}} | ||
{{/each}} | ||
*/ | ||
fastify.{{@key}}('{{../../subresource}}', async (request, reply) => { | ||
const options = { | ||
{{#if ../requestBody}} | ||
body: request.body{{#compare (lookup ../parameters 'length') 0 operator = '>' }},{{/compare}} | ||
{{/if}} | ||
{{#each ../parameters}} | ||
{{#equal this.in "query"}} | ||
{{{quote ../name}}}: request.query['{{../name}}']{{#unless @last}},{{/unless}} | ||
{{/equal}} | ||
{{#equal this.in "path"}} | ||
{{{quote ../name}}}: request.params['{{../name}}']{{#unless @last}},{{/unless}} | ||
{{/equal}} | ||
{{#equal this.in "header"}} | ||
{{{quote ../name}}}: request.header['{{../name}}']{{#unless @last}},{{/unless}} | ||
{{/equal}} | ||
{{/each}} | ||
}; | ||
console.log(options) | ||
try { | ||
const result = await fastify.{{../operationId}}(); | ||
{{#ifNoSuccessResponses ../responses}} | ||
reply.header('X-Result', result.data).code(200).send(); | ||
{{else}} | ||
reply.code(result.code || 200).send(result); | ||
{{/ifNoSuccessResponses}} | ||
} catch (err) { | ||
{{#ifNoErrorResponses ../responses}} | ||
reply.code(500).send({ | ||
status: 500, | ||
error: 'Server Error' | ||
}); | ||
{{else}} | ||
next(err); | ||
{{/ifNoErrorResponses}} | ||
} | ||
}); | ||
{{/validMethod}} | ||
{{/each}} | ||
{{/each}} | ||
|
||
{{#each operation}} | ||
{{#each this.path}} | ||
{{#validMethod @key}} | ||
/** | ||
{{#each ../descriptionLines}} | ||
* {{{this}}} | ||
{{/each}} | ||
*/ | ||
fastify.{{@key}}('{{../../subresource}}', async (request, reply) => { | ||
const options = { | ||
{{#if ../requestBody}} | ||
body: request.body{{#compare (lookup ../parameters 'length') 0 operator = '>' }},{{/compare}} | ||
{{/if}} | ||
{{#each ../parameters}} | ||
{{#equal this.in "query"}} | ||
{{{quote ../name}}}: request.query['{{../name}}']{{#unless @last}},{{/unless}} | ||
{{/equal}} | ||
{{#equal this.in "path"}} | ||
{{{quote ../name}}}: request.params['{{../name}}']{{#unless @last}},{{/unless}} | ||
{{/equal}} | ||
{{#equal this.in "header"}} | ||
{{{quote ../name}}}: request.header['{{../name}}']{{#unless @last}},{{/unless}} | ||
{{/equal}} | ||
{{#match @../key "(post|put)"}} | ||
{{#equal ../in "body"}} | ||
{{{quote ../name}}}: request.body['{{../name}}']{{#unless @last}},{{/unless}} | ||
{{/equal}} | ||
{{/match}} | ||
{{/each}} | ||
}; | ||
console.log(options) | ||
try { | ||
const result = await fastify.{{../operationId}}(); | ||
{{#ifNoSuccessResponses ../responses}} | ||
reply.code(200).send(result); | ||
{{else}} | ||
reply.code(200).send(result); | ||
{{/ifNoSuccessResponses}} | ||
} catch (err) { | ||
{{#ifNoErrorResponses ../responses}} | ||
reply.code(500).send({ | ||
status: 500, | ||
error: 'Server Error' | ||
}); | ||
{{else}} | ||
next(err); | ||
{{/ifNoErrorResponses}} | ||
} | ||
}); | ||
{{/validMethod}} | ||
{{/each}} | ||
{{/each}} | ||
next() | ||
} |
Oops, something went wrong.