After Init function or similar

Hello guys :vulcan_salute:

Is there possible to create a function or overwrite an existing one to run after Parse is initialized ?

What I mean is, for example you have some tables and roles designed but you’re developing in a local host, when you put it into production or any other server you need to start over.

Is possible a way to create all the schema and the roles by default?

Or any other idea?

Thanks

Parse Server configuration has a serverStartComplete option that is a callback called after the Parse Server has started. Search for serverStartComplete at http://parseplatform.org/parse-server/api/master/ParseServerOptions.html

I think it can help you to achieve what you need.

2 Likes

Here a short example (a stateless schema strategy for my part):

const server = ParseServer.start({
    databaseURI: process.env.MONGO_URL,
    cloud,
    appId: process.env.APP_ID,
    masterKey: process.env.MASTER_KEY,
    serverURL,
    graphQLPath: '/graphql',
    playgroundPath: '/playground',
    mountGraphQL: true,
    port: Number(process.env.PORT),
    startLiveQueryServer: true,
    mountPlayground: process.env.NODE_ENV !== 'production',
    serverStartComplete: async () => {
        await makeSchemas()
        console.log('Init finished')
    },
})
1 Like