mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-01-25 02:08:24 +00:00
add cors support
This commit is contained in:
@@ -28,8 +28,7 @@ HTTP_PORT=4000 node app
|
||||
#### Running the test suite
|
||||
To run the included test suite, you will need to have a mysql server installed on your laptop/server. You will need to set the MYSQL_ROOT_PASSWORD env variable to the mysql root password before running the tests. The test suite creates a database named 'jambones_test' in your mysql server to run the tests against, and removes it when done.
|
||||
```
|
||||
export MYSQL_ROOT_PASSWORD=foobar
|
||||
npm test
|
||||
MYSQL_ROOT_PASSWORD=foobar npm test
|
||||
```
|
||||
|
||||
#### Testing a deployed server
|
||||
|
||||
2
app.js
2
app.js
@@ -5,6 +5,7 @@ const opts = Object.assign({
|
||||
const logger = require('pino')(opts);
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const cors = require('cors');
|
||||
const bodyParser = require('body-parser');
|
||||
const passport = require('passport');
|
||||
const authStrategy = require('./lib/auth')(logger);
|
||||
@@ -15,6 +16,7 @@ passport.use(authStrategy);
|
||||
|
||||
app.locals.logger = logger;
|
||||
|
||||
app.use(cors());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(bodyParser.json());
|
||||
app.use('/v1', passport.authenticate('bearer', { session: false }));
|
||||
|
||||
@@ -156,7 +156,7 @@ CREATE TABLE IF NOT EXISTS `accounts`
|
||||
(
|
||||
`account_sid` CHAR(36) NOT NULL UNIQUE ,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sip_realm` VARCHAR(255),
|
||||
`sip_realm` VARCHAR(255) UNIQUE ,
|
||||
`service_provider_sid` CHAR(36) NOT NULL,
|
||||
`registration_hook` VARCHAR(255),
|
||||
PRIMARY KEY (`account_sid`)
|
||||
@@ -229,6 +229,7 @@ ALTER TABLE `subscriptions` ADD FOREIGN KEY registration_sid_idxfk (`registratio
|
||||
|
||||
CREATE INDEX `accounts_account_sid_idx` ON `accounts` (`account_sid`);
|
||||
CREATE INDEX `accounts_name_idx` ON `accounts` (`name`);
|
||||
CREATE INDEX `accounts_sip_realm_idx` ON `accounts` (`sip_realm`);
|
||||
CREATE INDEX `accounts_service_provider_sid_idx` ON `accounts` (`service_provider_sid`);
|
||||
ALTER TABLE `accounts` ADD FOREIGN KEY service_provider_sid_idxfk_1 (`service_provider_sid`) REFERENCES `service_providers` (`service_provider_sid`);
|
||||
|
||||
|
||||
@@ -371,7 +371,9 @@
|
||||
<SQLField>
|
||||
<name><![CDATA[sip_realm]]></name>
|
||||
<type><![CDATA[VARCHAR(255)]]></type>
|
||||
<indexed><![CDATA[1]]></indexed>
|
||||
<uid><![CDATA[CD99250E-6126-4CCA-A1F1-63FFFB028E63]]></uid>
|
||||
<unique><![CDATA[1]]></unique>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[service_provider_sid]]></name>
|
||||
@@ -1015,17 +1017,17 @@
|
||||
<overviewPanelHidden><![CDATA[0]]></overviewPanelHidden>
|
||||
<pageBoundariesVisible><![CDATA[0]]></pageBoundariesVisible>
|
||||
<PageGridVisible><![CDATA[0]]></PageGridVisible>
|
||||
<RightSidebarWidth><![CDATA[1756.000000]]></RightSidebarWidth>
|
||||
<RightSidebarWidth><![CDATA[1328.000000]]></RightSidebarWidth>
|
||||
<sidebarIndex><![CDATA[2]]></sidebarIndex>
|
||||
<snapToGrid><![CDATA[0]]></snapToGrid>
|
||||
<SourceSidebarWidth><![CDATA[0.000000]]></SourceSidebarWidth>
|
||||
<SQLEditorFileFormatVersion><![CDATA[4]]></SQLEditorFileFormatVersion>
|
||||
<uid><![CDATA[58C99A00-06C9-478C-A667-C63842E088F3]]></uid>
|
||||
<windowHeight><![CDATA[1417.000000]]></windowHeight>
|
||||
<windowLocationX><![CDATA[2985.000000]]></windowLocationX>
|
||||
<windowLocationX><![CDATA[3389.000000]]></windowLocationX>
|
||||
<windowLocationY><![CDATA[-0.000000]]></windowLocationY>
|
||||
<windowScrollOrigin><![CDATA[{0, 0}]]></windowScrollOrigin>
|
||||
<windowWidth><![CDATA[2033.000000]]></windowWidth>
|
||||
<windowWidth><![CDATA[1605.000000]]></windowWidth>
|
||||
</SQLDocumentInfo>
|
||||
<AllowsIndexRenamingOnInsert><![CDATA[1]]></AllowsIndexRenamingOnInsert>
|
||||
<defaultLabelExpanded><![CDATA[1]]></defaultLabelExpanded>
|
||||
|
||||
@@ -576,6 +576,10 @@ paths:
|
||||
type: number
|
||||
description: expiration requested, in seconds
|
||||
example: 3600
|
||||
scheme:
|
||||
type: string
|
||||
description: encryption protocol
|
||||
example: digest
|
||||
nonce:
|
||||
type: string
|
||||
description: nonce value
|
||||
@@ -596,7 +600,7 @@ paths:
|
||||
cnonce:
|
||||
type: string
|
||||
description: cnonce value
|
||||
example: 03d8d2aafd5a975f2b07dc90fe5f4100
|
||||
example: 6b8b4567
|
||||
nc:
|
||||
type: string
|
||||
description: nc value
|
||||
@@ -604,7 +608,7 @@ paths:
|
||||
response:
|
||||
type: string
|
||||
description: digest value calculated by the client
|
||||
example: db7b7dbec7edc0c427c1708031f67cc6
|
||||
example: be641cf7951ff23ab04c57907d59f37d
|
||||
responses:
|
||||
'200':
|
||||
description: |
|
||||
@@ -617,14 +621,14 @@ paths:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- response
|
||||
- status
|
||||
properties:
|
||||
response:
|
||||
status:
|
||||
type: string
|
||||
description: indicates whether the request was successfully authenticated
|
||||
enum:
|
||||
- ok
|
||||
- failed
|
||||
- fail
|
||||
example: ok
|
||||
message:
|
||||
type: string
|
||||
@@ -636,11 +640,11 @@ paths:
|
||||
The expires value to grant to the requesting user.
|
||||
If not provided, the expires value in the request is observed.
|
||||
If provided, must be less than the requested expires value.
|
||||
exileDuration:
|
||||
blacklist:
|
||||
type: number
|
||||
description: |
|
||||
If provided, represents a period in seconds during which the source IP
|
||||
address will be blacklisted by the platform.
|
||||
address will be blacklisted by the platform (-1 means forever).
|
||||
|
||||
get:
|
||||
summary: list accounts
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"config": "^3.2.4",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"mysql": "^2.17.1",
|
||||
"passport": "^0.4.0",
|
||||
|
||||
Reference in New Issue
Block a user