Closed rstormsf closed 9 years ago
We need to create a wiki page for these instructions. This is an awesome start.
Keep in mind these steps are needed for entirely new sections. If I'm adding to the admin for example, not all these steps are necessary.
To add a new model for the above we have to:
1)Add a model which will be available via
var Company = request.server.plugins['hapi-mongo-models'].Company;
to manifest.js
models: {
Account: './server/models/account',
AdminGroup: './server/models/admin-group',
Admin: './server/models/admin',
AuthAttempt: './server/models/auth-attempt',
Session: './server/models/session',
Status: './server/models/status',
User: './server/models/user',
Company: './server/models/company'
},
2)Create a model where you specified the path to it
Copy/paste user.js
and change all user references, amend a schema and define a collection.
Company._collection = 'company';
Thanks for taking the time to detail these things. :pray:
I'm wondering if there's a step missing. I'm trying to create an additional endpoint but I keep getting 403.
server.route({
method: 'POST',
path: options.basePath + '/foo',
config: {
tags: ['api'],
},
handler: function (request, reply) {
reply('bar')
}
});
There's no authentication required in this endpoint as you can see.
Found the issue. My bad. I was testing the api endpoint with the swagger-ui hapi plugin and forgot to add the X-CSRF-Token in the header.
@fjsousa good to hear.
I am creating a new API and defined model, api file and manifest but when ever I try to call it, it return 404. What i am missing :(
1) Modify
manifest.js
Create 2 routes for server-side react view:'./server/web/signup_company': {}
and api call: './server/api/signup_copmany': { basePath: '/api' }`2)in both 2 files make sure to:
don't currently understand how it works and why we need to do it
3)Client side: add some component to
client/pages/SIGNUP_COMPANY
make sure to have an index.jsx4)Add entry for
webpack
in./gulp/webpack.js
this will generate a file like:
5)add that script into server-side page(which is in
server/web/
) folder and in your<Layout feet={feet}
...</Layout>
I guess that is it?
what if we could just load ALL client side code in 1 file so we never have to deal with FOUC? I guess that's what makes it not true SPA app.