Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Apipie from 'apipie';
  2. // @flow
  3. import axios from 'axios';
  4.  
  5. axios.defaults.baseURL = 'http://sdm.ispaceup.com:8000';
  6.  
  7. type withData = boolean;
  8. type withQuery = boolean;
  9. // type requireAuth = boolean;
  10.  
  11. // const data: withData = true;
  12. // const params: withQuery = true;
  13. // const auth: requireAuth = true;
  14.  
  15. type httpMethod = 'get' | 'delete' | 'head' | 'post' | 'options' | 'put' | 'patch';
  16.  
  17. type Route = {
  18.   name: string,
  19.   method?: httpMethod,
  20.   url?: string,
  21.   meta?: {},
  22.   data?: withData,
  23.   params?: withQuery,
  24.   children?: Route[],
  25.   options?: {},
  26. }
  27.  
  28. const routes: Route[] = [
  29.   {
  30.     name: 'auth',
  31.     children: [
  32.       {
  33.         name: 'getLink',
  34.         url: '/auth/login/',
  35.         method: 'get',
  36.         auth: true,
  37.       },
  38.     ],
  39.   },
  40. ];
  41.  
  42. const apipie = new Apipie(routes, { axios });
  43.  
  44. const api = apipie.create();
  45.  
  46. export default api;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement