Skip to content

Commit 0999658

Browse files
authored
fix(rest): routing fix and moved cors to dependencies (#31)
Signed-off-by: Jan <jan@animo.id>
1 parent 2686699 commit 0999658

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

packages/rest/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,24 @@ Then add the rest package to your project.
4343
```sh
4444
yarn add @aries-framework/rest
4545
```
46+
47+
### Quick start
48+
49+
> The OpenAPI spec is generated using the OpenAPI Schema (Swagger). However this schema is not representing the real API. A lot of types are not correct. Keep this in mind when using this package.
50+
51+
Aries Framework JavaScript REST API provides a Swagger (OpenAPI) definition of the exposed API. After you start the REST API the generated API Client will be available on `/docs`.
52+
53+
### Example of usage
54+
55+
```ts
56+
import { startServer } from '@aries-framework/rest'
57+
58+
// The startServer function requires an initialized agent and a port.
59+
// An example of how to setup an agent is located in the `samples` directory.
60+
const run = async (agent: Agent) => {
61+
await startServer(agent, 3000)
62+
}
63+
64+
// A Swagger (OpenAPI) definition is exposed on http://localhost:3000/docs
65+
run()
66+
```

packages/rest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"class-transformer": "^0.4.0",
3030
"class-validator": "^0.13.1",
3131
"class-validator-jsonschema": "^3.1.0",
32+
"cors": "^2.8.5",
3233
"express": "^4.17.1",
3334
"ngrok": "^4.2.2",
3435
"reflect-metadata": "^0.1.13",
@@ -46,7 +47,6 @@
4647
"@types/supertest": "^2.0.11",
4748
"@types/swagger-ui-express": "^4.1.3",
4849
"@types/uuid": "^8.3.1",
49-
"cors": "^2.8.5",
5050
"jest": "^27.1.0",
5151
"patch-package": "^6.4.7",
5252
"supertest": "^6.1.6",

packages/rest/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const setupServer = async (agent: Agent) => {
1616
Container.set(Agent, agent)
1717

1818
const app: Express = createExpressServer({
19-
controllers: [__dirname + '/controllers/**/*.ts'],
19+
controllers: [__dirname + '/controllers/**/*.ts', __dirname + '/controllers/**/*.js'],
2020
cors: true,
2121
})
2222

0 commit comments

Comments
 (0)