Build a Secure Node.js App With SQL Server

David Neal

@disqus_PGNVpaKbow:disqus Glad to hear you figured it out! Thank you for sticking with it :slight_smile:

ACMAN ACENT

Hi David,

Thank you for the nice tutorial. I have getting the

error in connecting to the database below is the detail of the error can

you please help me in resolving it.

in the browser
{“statusCode”:500,“error”:“Internal Server Error”,“message”:“An internal server error occurred”}

in the console
Server running at http://localhost:8080
TypeError: Cannot read property ‘request’ of undefined
at Object.getEvents (E:\AcentJS\src\data\events\index.js:15:27)
at process._tickCallback (internal/process/next_tick.js:68:7)
Debug: internal, implementation, error
Error: handler method did not return a value, a promise, or throw an error
at module.exports.internals.Manager.execute (E:\AcentJS\node_modules\hapi\lib\toolkit.js:48:29)
at process._tickCallback (internal/process/next_tick.js:68:7)

Thanks.

Austin

Hey @disqus_PGNVpaKbow and David could you elaborate what you mean by “Use the npm execution tasks: initdb…”? Is that an npm command? I can’t quite figure out what you mean. Thank you in advance.

David Neal

Hi @disqus_kz9UBc4vsb There are some scripts defined in the package.json. You run those from the command line using npm run [script name]. In this case, npm run initdb. Hope this helps!

Jim Jones

Thanks for this write-up. It’s very helpful. Absolutely love the technique of putting all the sql into a folder and reading it into an array! Refactoring a project now to handle my sql spread throughout the codebase.

David Neal

You’re welcome! I’m glad to hear you found it useful!

Paloma

I would like to get this right in SQL Server management studio using windows auth

chris

Hi,

ty for your great walkthrough.

Iam stumpling over two issues. First SQL statement and API routes work

1)but my login page looks like plain html without any style (cant upload picture dont know why=
2) after I hit login button I get 400 bad request

Identitätsanbieter: Unknown
Fehlercode: invalid_request
Beschreibung: The ‘redirect_uri’ parameter must be an absolute URI that is whitelisted in the client app settings.

Ravi T

David, I added console.log(err) and the error indicates TypeError: Invalid server: undefined

David Neal

The complete source code for the tutorial is available on GitHub at https://github.com/oktadeve…. You might try running that code or comparing your code to that project to see if there’s a step missing. I hope this helps!

Prabowo Agung

Thanks for the nice tutorial, y the way, how to create dynamic routes/api/… any modules? So I can create more than one module. In this project you create src/routes/api/index.js and events.js with events.js is imported to index.js. When I want to add new module, for example users module, how to add this users modules to route so I can access via api/users? How if there are many modules?

Kyle Johnson

I’m getting the same error. Did you work out a solution. Thanks!

Kyle Johnson

Ravi - did you find a solution to your problem. I am getting the same error. Thanks!

Kyle Johnson

Hi - I’m not sure why, but when i replaced pool = await sql.connect( in src>data>index.js with the actual connection values, it connected fine. So the problem seems to be somewhere between the config file, .env or something like that.

nouman arshad

{“statusCode”:400,“error”:“Bad Request”,“message”:“Invalid cookie value”}
I am getting this error , and api 404 then , I repeated many time this demo , server running but giving above error

Su Gia

Hi David,
I appreciate your nice post.
I’m getting error at authentication as below

startup error: Error [ValidationError]: {
“password”: “secret”,
“redirectTo”: “/authorization-code/callback”,
“isSecure”: false,
“cookie” [1]: – missing –
}

[1] “password” is required
at Object.exports.process (D:\Sample Source\EventCalendar\node_modules\joi\lib\errors.js:203:19)
I also attached the image of this issue.

Please take a look and give me your idea.
Thank you,

Su Gia

Hi Hugo,
I also get the same issue, do you have the answer? Please let me know. Thanks.

Benja Ramírez

Hi David. Thank you so much for this tutorial, you are a great teacher. But I’m having some problems, because my users are in a SQL table and not in Okta. Can you show me some example doing an auth with this specifications?

TipTop

For the second part where you add authentication via okta to your tutorial: The Site and structure / UI has completeley changed after creating an account , what should i do now because there is no reference data there after signing up and wanting to add the app.

Hi. Thanks for the tut. It all works great, no errors but - no data is returned and I can’t add a new record. I know the connection is good because tasks: initdb runs fine.
I put a debug stop on client/App.vue in the loadEvents() call. It runs without error but still no data in res.data. Any tips on what I can try?
Thanks all.