mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05:28 +02:00
Add missing routes to mirage
This commit is contained in:
parent
6ca10b277c
commit
f4b003525d
2 changed files with 245 additions and 83 deletions
|
@ -1,90 +1,248 @@
|
||||||
export default function() {
|
export default function() {
|
||||||
|
|
||||||
// These comments are here to help you get started. Feel free to delete them.
|
this.passthrough('https://widget.intercom.io/widget/%7Bapp_id%7D');
|
||||||
|
this.urlPrefix = 'https://localhost:5001'; // make this `http://localhost:8080`, for example, if your API is on a different server
|
||||||
|
this.namespace = 'api'; // make this `api`, for example, if your API is namespaced
|
||||||
|
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
||||||
|
|
||||||
/*
|
this.get('/public/meta', function () {
|
||||||
Config (with defaults).
|
return {
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
Note: these only affect routes defined *after* them!
|
"title":"EmberSherpa",
|
||||||
*/
|
"message":"This Documize instance contains all our team documentation",
|
||||||
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
"url":"",
|
||||||
this.namespace = 'api/public'; // make this `api`, for example, if your API is namespaced
|
"allowAnonymousAccess":true,
|
||||||
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
"version":"11.2"
|
||||||
|
};
|
||||||
/*
|
|
||||||
Route shorthand cheatsheet
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
GET shorthands
|
|
||||||
|
|
||||||
this.get()
|
|
||||||
|
|
||||||
// Collections
|
|
||||||
this.get('/contacts');
|
|
||||||
this.get('/contacts', 'users');
|
|
||||||
this.get('/contacts', ['contacts', 'addresses']);
|
|
||||||
|
|
||||||
// Single objects
|
|
||||||
this.get('/contacts/:id');
|
|
||||||
this.get('/contacts/:id', 'user');
|
|
||||||
this.get('/contacts/:id', ['contact', 'addresses']);
|
|
||||||
*/
|
|
||||||
|
|
||||||
this.get('/authenticate', function() {
|
|
||||||
return {
|
|
||||||
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
POST shorthands
|
|
||||||
|
|
||||||
this.post('/contacts');
|
|
||||||
this.post('/contacts', 'user'); // specify the type of resource to be created
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
PUT shorthands
|
|
||||||
|
|
||||||
this.put('/contacts/:id');
|
|
||||||
this.put('/contacts/:id', 'user'); // specify the type of resource to be updated
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
DELETE shorthands
|
|
||||||
|
|
||||||
this.del('/contacts/:id');
|
|
||||||
this.del('/contacts/:id', 'user'); // specify the type of resource to be deleted
|
|
||||||
|
|
||||||
// Single object + related resources. Make sure parent resource is first.
|
|
||||||
this.del('/contacts/:id', ['contact', 'addresses']);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function fallback. Manipulate data in the db via
|
|
||||||
|
|
||||||
- db.{collection}
|
|
||||||
- db.{collection}.find(id)
|
|
||||||
- db.{collection}.where(query)
|
|
||||||
- db.{collection}.update(target, attrs)
|
|
||||||
- db.{collection}.remove(target)
|
|
||||||
|
|
||||||
// Example: return a single object with related models
|
|
||||||
this.get('/contacts/:id', function(db, request) {
|
|
||||||
var contactId = +request.params.id;
|
|
||||||
|
|
||||||
return {
|
|
||||||
contact: db.contacts.find(contactId),
|
|
||||||
addresses: db.addresses.where({contact_id: contactId})
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
*/
|
this.get('/public/validate', function (db, request) {
|
||||||
}
|
let serverToken = request.queryParams.token;
|
||||||
|
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0"
|
||||||
|
|
||||||
/*
|
if(token = serverToken){
|
||||||
You can optionally export a config that is only loaded during tests
|
return {
|
||||||
export function testConfig() {
|
"id":"VzMuyEw_3WqiafcE",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"firstname":"Lennex",
|
||||||
|
"lastname":"Zinyando",
|
||||||
|
"email":"brizdigital@gmail.com",
|
||||||
|
"initials":"LZ",
|
||||||
|
"active":true,
|
||||||
|
"editor":true,
|
||||||
|
"admin":true,
|
||||||
|
"accounts":[{
|
||||||
|
"id":"VzMuyEw_3WqiafcF",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"admin":true,
|
||||||
|
"editor":true,
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"company":"EmberSherpa",
|
||||||
|
"title":"EmberSherpa",
|
||||||
|
"message":"This Documize instance contains all our team documentation",
|
||||||
|
"domain":""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
this.get('/users/0/permissions', function () {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"folderId":"VzMygEw_3WrtFzto",
|
||||||
|
"userId":"",
|
||||||
|
"canView":true,
|
||||||
|
"canEdit":false
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/templates', function () {
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/folders/VzMuyEw_3WqiafcG', function () {
|
||||||
|
return {
|
||||||
|
"id":"VzMuyEw_3WqiafcG",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"name":"My Project",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"folderType":2
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/documents', function (db, request) {
|
||||||
|
let folder_id = request.queryParams.folder;
|
||||||
|
|
||||||
|
if (folder_id = "VzMuyEw_3WqiafcG"){
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id":"VzMwX0w_3WrtFztd",
|
||||||
|
"created":"2016-05-11T13:15:11Z",
|
||||||
|
"revised":"2016-05-11T13:22:16Z",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"folderId":"VzMuyEw_3WqiafcG",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"job":"",
|
||||||
|
"location":"template-0",
|
||||||
|
"name":"Empty Document",
|
||||||
|
"excerpt":"My test document",
|
||||||
|
"tags":"",
|
||||||
|
"template":false
|
||||||
|
},{
|
||||||
|
"id":"VzMvJEw_3WqiafcI",
|
||||||
|
"created":"2016-05-11T13:09:56Z",
|
||||||
|
"revised":"2016-05-11T13:09:56Z",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"folderId":"VzMuyEw_3WqiafcG",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"job":"0bf9b076-cb74-4e8e-75be-8ee2d24a8171",
|
||||||
|
"location":"/var/folders/d6/kr81d2fs5bsbm8rz2p092fy80000gn/T/documize/_uploads/0bf9b076-cb74-4e8e-75be-8ee2d24a8171/README.md",
|
||||||
|
"name":"README",
|
||||||
|
"excerpt":"To Document/ Instructions. GO. go- bindata- assetsfs. SSL.",
|
||||||
|
"tags":"",
|
||||||
|
"template":false
|
||||||
|
}
|
||||||
|
];
|
||||||
|
} else if (folder_id = "VzMygEw_3WrtFzto"){
|
||||||
|
return {
|
||||||
|
"id":"VzMygEw_3WrtFzto",
|
||||||
|
"created":"2016-05-11T13:24:17Z",
|
||||||
|
"revised":"2016-05-11T13:25:51Z",
|
||||||
|
"name":"Test",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"folderType":1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/folders', function() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id":"VzMuyEw_3WqiafcG",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"name":"My Project","orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"folderType":2
|
||||||
|
},{
|
||||||
|
"id":"VzMygEw_3WrtFzto",
|
||||||
|
"created":"2016-05-11T13:24:17Z",
|
||||||
|
"revised":"2016-05-11T13:25:51Z",
|
||||||
|
"name":"Test",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"folderType":1
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.post('/public/authenticate', () => {
|
||||||
|
return {
|
||||||
|
"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
|
||||||
|
"user":{
|
||||||
|
"id":"VzMuyEw_3WqiafcE",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"firstname":"Lennex",
|
||||||
|
"lastname":"Zinyando",
|
||||||
|
"email":"brizdigital@gmail.com",
|
||||||
|
"initials":"LZ",
|
||||||
|
"active":true,
|
||||||
|
"editor":true,
|
||||||
|
"admin":true,
|
||||||
|
"accounts":[
|
||||||
|
{
|
||||||
|
"id":"VzMuyEw_3WqiafcF",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"admin":true,
|
||||||
|
"editor":true,
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"company":"EmberSherpa",
|
||||||
|
"title":"EmberSherpa",
|
||||||
|
"message":"This Documize instance contains all our team documentation",
|
||||||
|
"domain":""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/users/VzMuyEw_3WqiafcE/permissions', () => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"folderId":"VzMuyEw_3WqiafcG",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"canView":true,
|
||||||
|
"canEdit":true
|
||||||
|
},{
|
||||||
|
"folderId":"VzMygEw_3WrtFzto",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"canView":true,
|
||||||
|
"canEdit":true
|
||||||
|
},{
|
||||||
|
"folderId":"VzMygEw_3WrtFzto",
|
||||||
|
"userId":"",
|
||||||
|
"canView":true,
|
||||||
|
"canEdit":false
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/folders/VzMygEw_3WrtFzto', () => {
|
||||||
|
return {
|
||||||
|
"id":"VzMygEw_3WrtFzto",
|
||||||
|
"created":"2016-05-11T13:24:17Z",
|
||||||
|
"revised":"2016-05-11T13:25:51Z",
|
||||||
|
"name":"Test",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"folderType":1
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/folders/VzMuyEw_3WqiafcG', () => {
|
||||||
|
return {
|
||||||
|
"id":"VzMuyEw_3WqiafcG",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"name":"My Project",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"folderType":2
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/folders/VzMuyEw_3WqiafcG', () => {
|
||||||
|
return {
|
||||||
|
"id":"VzMuyEw_3WqiafcG",
|
||||||
|
"created":"2016-05-11T15:08:24Z",
|
||||||
|
"revised":"2016-05-11T15:08:24Z",
|
||||||
|
"name":"My Project",
|
||||||
|
"orgId":"VzMuyEw_3WqiafcD",
|
||||||
|
"userId":"VzMuyEw_3WqiafcE",
|
||||||
|
"folderType":2
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
very helpful for debugging
|
||||||
*/
|
*/
|
||||||
|
this.handledRequest = function(verb, path, request) {
|
||||||
|
console.log(`👊${verb} ${path}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.unhandledRequest = function(verb, path, request) {
|
||||||
|
console.log(`🔥${verb} ${path}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -22,7 +22,11 @@
|
||||||
"andThen",
|
"andThen",
|
||||||
"currentURL",
|
"currentURL",
|
||||||
"currentPath",
|
"currentPath",
|
||||||
"currentRouteName"
|
"currentRouteName",
|
||||||
|
"stubSession",
|
||||||
|
"stubAudit",
|
||||||
|
"pauseTest",
|
||||||
|
"userLogin"
|
||||||
],
|
],
|
||||||
"node": false,
|
"node": false,
|
||||||
"browser": false,
|
"browser": false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue