Giter Site home page Giter Site logo

Comments (13)

egoist avatar egoist commented on April 27, 2024

context is only available on server-side.

from deprecated.

ansarizafar avatar ansarizafar commented on April 27, 2024

I am logging context on the server side but Context argument is undefined in createRouter function for the path "/" and other routes on server-side. Is it possible to use req object in router.beforeEach callback on the server. I am tryinfg to implement global navigation guard on the server.

from deprecated.

egoist avatar egoist commented on April 27, 2024

I guess we need to implement a server-side redirect method in context, using the native next function in beforeEach((to, from, next) => {}) would not work.

from deprecated.

egoist avatar egoist commented on April 27, 2024

Hmm, didn't understand you correctly, do you mean something like this?

router.beforeEach((to, from, next) => {
  if (to.path === '/private') {
    if (process.server && !context.req.session) {
      return next('/')
    }
    if (process.browser && !localStorage.getItem('api-key')) {
      return next('/')
    }
  }
  next()
})

from deprecated.

ansarizafar avatar ansarizafar commented on April 27, 2024

Yes I am trying to do just that with some modifications but I am unable to use custom express server with ream and backpack module. Nuxt works fine with custom express server and backpack https://github.com/nuxt/express. Is ream compatible with backpack? Ream is much better than Nuxt If can solve few issues.

from deprecated.

egoist avatar egoist commented on April 27, 2024

So is this issue solved already? I can see context:

2017-06-11 9 12 35

Is ream compatible with backpack?

What issues do you run into while using Ream with Backpack? It's just a cli tool to run your node app, so I think it will work fine with Ream. Keep in mind that while using custom express server it's just a normal node app. A repo for reproducing the issue will help a lot.

from deprecated.

ansarizafar avatar ansarizafar commented on April 27, 2024

Yes after updating to rc.5 context is available in createRouter function. I am trying to build a full stack template with jwt token based authentication/ authorization and a graphql inspired simple data layer with request batching. VueJs is realy great and there should be a full-stack framework based on it.

I am using code from template-ream with my own server code

const dev = process.env.NODE_ENV !== 'production'
const client = ream({dev: dev, entry: 'src/client/index.js'})
  
client.prepare()
  .then(() => {
    app.get('*', client.getRequestHandler())
this.instance = app.listen(process.env.PORT || 5000,
 (err) => {
if(err) {
   Log.error(`Unable to start API server ${process.pid}.`);
   Event.emit('shutdown')
} else {
          Log.info(`API server ${process.pid} started...`);
    }
});
  })

client.on('ready', () => {
  ream.displayStats(client.stats)
  })

Pacjage.json

 "start": "backpack build && node ./build/main.js"

Build is successful and server is started. Here is the output

image

Build also not working with Neutrino, Neutrino Node.js Preset modules

✖ Building project failed
4:01 PM
Jump to
./src/index.js
4:01 PM
Module build failed: Error: Target version must be a number,
4:01 PM
Jump to
'6.9' was given for 'node' (While processing preset: "/app/node_modules/babel-preset-env/lib/index.js")
4:01 PM
Jump to
at /app/node_modules/babel-preset-env/lib/index.js:64:13
4:01 PM
    at Array.filter (native)
4:01 PM
Jump to

from deprecated.

ansarizafar avatar ansarizafar commented on April 27, 2024

It seems that babel-preset-env module is defining node version number as a string and not as a number. Both backback and Neutrino reporting same error. @egoist Could you please suggest a solution.

from deprecated.

egoist avatar egoist commented on April 27, 2024

that's weird, we didn't define the node version in babel-preset-env

from deprecated.

ansarizafar avatar ansarizafar commented on April 27, 2024

@egoist My project is hosted on glitch.com. If you can share your email then I can send you an invite on glitch.com

from deprecated.

egoist avatar egoist commented on April 27, 2024

yup, you can find my email on my profile page

from deprecated.

ansarizafar avatar ansarizafar commented on April 27, 2024

@egoist I just sent you an invitation of my project on glitch.com

from deprecated.

ansarizafar avatar ansarizafar commented on April 27, 2024

It's working now thanks for the help.

from deprecated.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.