Help deploy a node.js server on railway

Nnikivi5/19/2023
I want to deploy some node code with railway
Nnikivi5/19/2023
Nnikivi5/19/2023
i started with template but its strange
Nnikivi5/19/2023
its using .mjs
Nnikivi5/19/2023
Nnikivi5/19/2023
my code is like this
Nnikivi5/19/2023
can I deploy this
Nnikivi5/19/2023
or i need to make changes
Bbrody5/19/2023
yes the project is in the format of a node module
Nnikivi5/19/2023
not sure what you mean
Nnikivi5/19/2023
I wonder if I can just run railway link
Nnikivi5/19/2023
and it will deploy
Bbrody5/19/2023
this might be more what you want
https://github.com/brody192/express-simple
Bbrody5/19/2023
that isn't quite how it works
Bbrody5/19/2023
you will want to fork that repo, clone it to your computer, make the changes you want, push the changes to github, then add a new service from that repo you forked
Nnikivi5/19/2023
thanks will try now
Bbrody5/19/2023
cool!
Nnikivi5/25/2023
hey @Brody
Nnikivi5/25/2023
i am trying to deploy this project with railway now
Bbrody5/25/2023
any problems?
Nnikivi5/25/2023
testing it out on stripe side
Nnikivi5/25/2023
actually was magical
Nnikivi5/25/2023
Nnikivi5/25/2023
i did it via ui
Bbrody5/25/2023
oh so no issues?
Nnikivi5/25/2023
im trying to change stuff on stripe side
Nnikivi5/25/2023
to point to prod url
Nnikivi5/25/2023
@Brody can i get logs in railway
Nnikivi5/25/2023
oh ok i see it
Nnikivi5/25/2023
Nnikivi5/25/2023
mm
Nnikivi5/25/2023
doesn't seem to work
Bbrody5/25/2023
you changed the template
Bbrody5/25/2023
well duh lol
Bbrody5/25/2023
i mean you changed the part of it that allowed it to work effortlessly on railway
Nnikivi5/25/2023
im looking at yours now
Bbrody5/25/2023
please read this docs page to get you back on track
https://docs.railway.app/troubleshoot/fixing-common-errors
Nnikivi5/25/2023
const port = process.env.PORT || 3000

app.listen(port, () => console.log(`Running on port ${port}`))
Nnikivi5/25/2023
ok so i added this
Nnikivi5/25/2023
its still failing
Nnikivi5/25/2023
unless i miss something else
Bbrody5/25/2023
failing how?
Nnikivi5/25/2023
the thing though
Nnikivi5/25/2023
well web hooks don't get sent to that url
Nnikivi5/25/2023
maybe its a stripe issue
Bbrody5/25/2023
send me the railway domain for that service?
Nnikivi5/25/2023
stripe-payment-hooks-production.up.railway.app
Nnikivi5/25/2023
btw feature request is so copy gives full url
Nnikivi5/25/2023
with https://
Nnikivi5/25/2023
not sure why it only gives raw thing
Bbrody5/25/2023
yep, the app works fine
Nnikivi5/25/2023
ok then will ask on stripe side
Bbrody5/25/2023
stripe will have some type of logs for why it fails, send them over
Bbrody5/25/2023
and im sure they have a test the webhook endpoint button or something right?
Nnikivi5/25/2023
Nnikivi5/25/2023
before deploying i was working with it locally
Nnikivi5/25/2023
and it worked
Nnikivi5/25/2023
stripe listen --forward-to localhost:4242/webhook
Nnikivi5/25/2023
i ran this
Bbrody5/25/2023
what endpoint do you have registered to handle the stripe webhooks
Nnikivi5/25/2023
and node index.js
Nnikivi5/25/2023
Bbrody5/25/2023
in code
Nnikivi5/25/2023
im not sure i get you
Nnikivi5/25/2023
is my code for stripe web hooks
Nnikivi5/25/2023
Nnikivi5/25/2023
i get a checkout page like this
Nnikivi5/25/2023
        const normalMonthly = await stripe.checkout.sessions.create({
          success_url: process.env.STRIPE_SUCCESS_URL!,
          mode: "subscription",
          metadata: {
            userDetailsId: userDetailsId,
          },
          line_items: [
            {
              quantity: 1,
              price: process.env.STRIPE_NORMAL_MONTH_SUBSCRIPTION!,
            },
          ],
        })
Nnikivi5/25/2023
created like so
Nnikivi5/25/2023
then when users complete the checkout
Nnikivi5/25/2023
web hooks should get sent to this railway endpoint
Bbrody5/25/2023
your endpoint is /webhook
you need to tell stripe to call that endpoint
Nnikivi5/25/2023
Nnikivi5/25/2023
ok trying with this
Bbrody5/25/2023
you are missing the /webhook endpoint here
Nnikivi5/25/2023
Nnikivi5/25/2023
thank you that worked
Bbrody5/25/2023
awsome
Bbrody5/25/2023
for node apps that you have full control over the codebase, its best to define the start command/script in the package.json file, but i see you dont have one