Skip to content

Commit 56a508a

Browse files
committed
add cors and swagger options in manifest
1 parent 951cebb commit 56a508a

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

manifest.js

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,68 @@ const devPlugins = [
4848
{
4949
plugin: 'hapi-swagger',
5050
options: {
51+
securityDefinitions: {
52+
'jwt': {
53+
'type': 'apiKey',
54+
'name': 'Authorization',
55+
'in': 'header'
56+
}
57+
},
58+
security: [{ 'jwt': [] }],
5159
info: {
5260
title: `${Config.get('/projectName')} API Documentation`,
53-
version: Pack.version
61+
version: Pack.version,
62+
description: `Check out the **[Github Wiki](https://github.com/escommunity/fresh/wiki)** for common questions and how-tos.
63+
64+
A few key things to be aware of:
65+
The core User model found in the /endpoint/v1/users/ endpoints have these basic fields: _id, email, username, password, isActive, roles, timeCreated.
66+
67+
This framework decorates the core User models with additional role specific fields via mapping it to 1 or more roles. Fresh comes with 2 default roles, customers and admins.
68+
69+
/endpoint/v1/accounts/ is the "customer account" role.
70+
When users sign up via /endpoint/v1/signup the framework automatically creates a new User and a new Account (aka customer role) and links the two. Users can have multiple roles but each new instance of a role model can only be mapped to one user.
71+
The customer Account role adds these additional fields for users who are customers: "name" (first, last), "notes", and "status". "Notes" allows admins to add notes to accounts.
72+
73+
/endpoint/v1/admins/ is the "admin" role.
74+
This role contains a "name" (first, last), "permissions", and "groups" property allowing you to assign multiple admin-groups. The first admin-group is "root" which is allowed to perform the "Root Scope" actions.
75+
76+
More details on [Users, Roles & Groups](https://github.com/escommunity/fresh/wiki/Users,-Roles-&-Groups)
77+
More details on [Admin & Admin Group Permissions](https://github.com/escommunity/fresh/wiki/Admin-&-Admin-Group-Permissions)`
5478
},
55-
grouping: 'tags'
79+
grouping: 'tags',
80+
sortTags: 'name',
81+
tags: [
82+
{
83+
name: 'accounts',
84+
description: 'endpoints to interact with customer role.'
85+
}, {
86+
name: 'admin-groups',
87+
description: 'endpoints to interact with admin groups.'
88+
}, {
89+
name: 'admins',
90+
description: 'endpoints to interact with admin roles.'
91+
}, {
92+
name: 'contact'
93+
}, {
94+
name: 'login',
95+
description: 'endpoints for login flow.'
96+
}, {
97+
name: 'logout'
98+
}, {
99+
name: 'main'
100+
}, {
101+
name: 'session',
102+
description: 'endpoints to interact with user sessions.'
103+
}, {
104+
name: 'signup'
105+
}, {
106+
name: 'statuses',
107+
description: 'endpoints to interact with customer role (account) statuses.'
108+
}, {
109+
name: 'users',
110+
description: 'endpoints to interact with users (outside of roles)'
111+
}
112+
]
56113
}
57114
},
58115
{
@@ -193,6 +250,12 @@ const manifest = {
193250
}
194251
},
195252
files: { relativeTo: Config.get('/publicPath') },
253+
cors: {
254+
origin: ['*'],
255+
maxAge: 86400,
256+
headers: ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'],
257+
credentials: true
258+
},
196259
security: true
197260
},
198261
port: Config.get('/port/web')

0 commit comments

Comments
 (0)