jedireza / aqua

:bulb: A website and user system starter
https://jedireza.github.io/aqua/
MIT License
1.38k stars 358 forks source link

path to add features #58

Closed rstormsf closed 9 years ago

rstormsf commented 9 years ago

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:


exports.register.attributes = {
    name: ''
};

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.jsx

4)Add entry for webpack in ./gulp/webpack.js

signup_company: './client/pages/signup_company/index'

this will generate a file like:

var feet = <script src="/public/pages/signup_company.min.js"></script>;

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.

jedireza commented 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.

rstormsf commented 9 years ago

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';

jedireza commented 9 years ago

Thanks for taking the time to detail these things. :pray:

fjsousa commented 9 years ago

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.

fjsousa commented 9 years ago

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.

jedireza commented 9 years ago

@fjsousa good to hear.

nitingautam commented 7 years ago

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 :(