Need assistance with hosting JS-web project
Hello, im trying to host an Assistants discord bot Dashboard.
I need help with deploying and domain installing
Solution:Jump to solution
don't put tokens of any kind on code, use service variables
https://docs.railway.app/develop/variables
add the missing fields to the package.json, you could find the missing fields online or from doing
npm init
in another folder, and looking at the newly created package.json...81 Replies
Project ID:
e5992fe2-93c8-4531-949c-97634b766726
please share your repo
One second
GitHub
GitHub - Ruddien/DashBoard
Contribute to Ruddien/DashBoard development by creating an account on GitHub.
that's not a valid package.json
Im using example package.json.
xxx - just for not sharing my tokens to public
If it`s wrong, what should i do?
Solution
don't put tokens of any kind on code, use service variables
https://docs.railway.app/develop/variables
add the missing fields to the package.json, you could find the missing fields online or from doing
npm init
in another folder, and looking at the newly created package.jsonI searched for a variables, and how i should paste they in the code?
In what form?
For example, that one
Sry for dumb q
please read the docs page I linked, if you for instance had a discord token, you would set a service variable
DISCORD_TOKEN
to your discord token, then in JavaScript you access that service variables by using process.env.DISCORD_TOKEN
the variable you show me here is already automatically set for you, to access it just use process.env.RAILWAY_PUBLIC_DOMAIN
in your codeThat way?
don't string quote it
It causes
It`s a json file, config
ah that's a json file, you can only use process.env in JavaScript
Oh, i dont need a config file
I can directly put it on index
but the bigger issue being your package.json is still not valid
I start from begin
Now it should be valid
have you just pushed a new change to your repo?
you would need a start script, but other than the missing start script, it looks fine
Like that?
perfect
please also read this https://docs.railway.app/troubleshoot/fixing-common-errors
since you are running a web server
Im sorry, i have some ex. but im too busy last days.Like that?:
looks good
For that variable i should use
proccess.env.Domain
?Just an example variable
not too sure why you need to set a domain variable, just use
process.env.RAILWAY_PUBLIC_DOMAIN
directly in codeYea, i know it
It`s just an example
what domain do you want to set? they're just in
KEY=value
format
and per the standard, the key is always fully capitalised, with underscores to separate wordsproccess.env.TOKEN
?the key (variable name) should be all capital case
you have it lowercase
I should name they with capitals only?
yes always use full capital case when naming service / environment variables
nothing bad happens if you don't, but it's just standard to do so
perfect
So keep it like this
in the code it should be : proccess.env.TOKEN?
correct
Ok, i will fill everything now and will try again.
port variable in the code: proccess.env.PORT?
Or i should create a variable named "PORT"?
the field names in the object you give to
DBD.Dashboard
shouldn't be capital case, the capital case only applies to service / environment variable names.
but the value you give to the port
option should be process.env.PORT || 3000
a PORT
variables is automatically generated for you by railway, you don't need to set your own
using that double pipe means that when you deploy to railway your app runs with the PORT
railway wants your app to run with, and when running locally a PORT
environment variable won't exist so your app will run on port 3000looks good
What i should do with it?
I transfered everything from config to index (using process.env)
I don't know what any of that is
you haven't done anything with it in your original code, so you don't need to do anything about it now I would presume
My index part
I asked in off. discord server
the environment variable side of things is looking good to me, but keep in mind I have never used or even heard of
discord-dashboard
before you opened this threadBTW, i need to install npm packages or process.env will automatically work when i deploy it to the railway?
it will automatically work, it's a core api of node
locally you don't have any of these service / environment variables set, they are only set on Railway, so once you get this running on railway we can talk about how you can use the railway service variables locally too
@Brody
does your app require command line input from the user?
No, as i know
wait a sec..
only when u instaling package
looks like its trying to ask for some kind of input, apps on railway have to run essentially headless and autonomously
So it`s no way , if it need a console input?
the opposite, its trying to get console input
input*
you would need to consult the discord-dashboard docs for this one
It should be the solution
that seems like exactly what you want to do!
it works!
finally
Can i share a link to u for a testing aim?
checking aim?
Sorry, not a native speaker
no worries
Can i post my website link to let u test it
Wanna be sure
sure
looks fine to me
Thank you too much for assisting !
U my little hero 🙂
ah how sweet
It was a big pleasure to work with u.
thank you, and you learn fast!
Thank u so much for ur patience
Have a good day and never get upset
haha thank you, have agood day yourself too