{"id":20307347,"url":"https://github.com/oktadev/okta-node-sql-server-example","last_synced_at":"2025-04-11T15:11:45.915Z","repository":{"id":40951331,"uuid":"172148821","full_name":"oktadev/okta-node-sql-server-example","owner":"oktadev","description":"Build a Node.js App with SQL Server Tutorial","archived":false,"fork":false,"pushed_at":"2023-03-02T19:38:48.000Z","size":2659,"stargazers_count":33,"open_issues_count":11,"forks_count":25,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-25T11:21:23.978Z","etag":null,"topics":["hapi","nodejs","sqlserver","vue"],"latest_commit_sha":null,"homepage":"https://developer.okta.com/blog/2019/03/11/node-sql-server","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oktadev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-22T23:35:55.000Z","updated_at":"2024-06-28T09:27:05.000Z","dependencies_parsed_at":"2023-02-08T14:31:14.805Z","dependency_job_id":null,"html_url":"https://github.com/oktadev/okta-node-sql-server-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-sql-server-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-sql-server-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-sql-server-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-sql-server-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oktadev","download_url":"https://codeload.github.com/oktadev/okta-node-sql-server-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429111,"owners_count":21101783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hapi","nodejs","sqlserver","vue"],"created_at":"2024-11-14T17:17:18.915Z","updated_at":"2025-04-11T15:11:45.883Z","avatar_url":"https://github.com/oktadev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Build a Secure Node.js App with SQL Server\n\nThis is a sample application for the article [Build a Secure Node.js App with SQL Server](https://developer.okta.com/blog/2019/03/11/node-sql-server).\n\nBuilt with love, using:\n\n* [Node.js](https://nodejs.org/en/)\n* [SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-2017)\n* [hapi](https://hapijs.com/)\n* [Vue.js](https://vuejs.org/)\n\n## Requirements\n\n* [Node.js](https://nodejs.org/en/) version 8.0 or higher\n* [SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-2017) version 2012 or higher\n\nIf you don't already have access to SQL Server, you can install one locally for development and testing.\n\n### Install SQL Server on Windows\n\nDownload and install [SQL Server Developer Edition](https://www.microsoft.com/en-us/sql-server/sql-server-downloads).\n\n### Install SQL Server on Mac or Linux\n\n1. Install [Docker](https://docs.docker.com/docker-for-mac/install/)\n1. Run the following in a terminal. Change the values of `name_your_container` and `SA_PASSWORD=P@55w0rd` to what you desire.\n\n```bash\ndocker pull microsoft/mssql-server-linux:2017-latest\ndocker run -d --name name_your_container -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@55w0rd' -e 'MSSQL_PID=Developer' -p 1433:1433 microsoft/mssql-server-linux:2017-latest\n```\n\n\u003e Note: For more information on running SQL Server for Linux, see [SQL Server Running on a Mac?!](https://medium.com/@reverentgeek/sql-server-running-on-a-mac-3efafda48861)\n\n## Set Up Local Development Environment\n\n1. Clone this repository (or download and extract the zip file)\n2. Open a command prompt or terminal\n3. Change to the directory that contains the project files\n4. Run `npm install` to install all the dependencies\n5. Copy `.env.sample` to `.env`, and modify the settings to match your environment\n\n```bash\n# hapi server configuration\nPORT=8080\nHOST=localhost\nHOST_URL=http://localhost:8080\nCOOKIE_ENCRYPT_PWD=superAwesomePasswordStringThatIsAtLeast32CharactersLong!\n\n# SQL Server connection\nSQL_USER=dbuser\nSQL_PASSWORD=P@55w0rd\nSQL_DATABASE=calendar\nSQL_SERVER=servername\n# Change SQL_ENCRYPT=true if using Azure\nSQL_ENCRYPT=false\n\n# Okta configuration\nOKTA_ORG_URL=https://{yourOktaDomain}\nOKTA_CLIENT_ID={yourClientId}\nOKTA_CLIENT_SECRET={yourClientSecret}\n```\n\n### Initialize Your SQL Database\n\nYou will need a SQL database to for this application. If you are running SQL Server locally and don't already have a database, you can create one with the following script. You can use a utility like [Azure Data Studio](https://docs.microsoft.com/en-us/sql/azure-data-studio/download?view=sql-server-2017) to connect to your instance to run this script.\n\n```sql\nUSE master;\nGO\n\nCREATE DATABASE calendar; -- change this to whatever database name you desire\nGO\n```\n\nNext you can run the following task at the command line or terminal to initialize your database. \n\n\u003e Note: Make sure you have the correct server, database, user, and password configured in your `.env` file.\n\n```bash\nnpm run tasks:initdb\n```\n\n### Easily Add Authentication to Your Applications with Okta\n\nThis application uses Okta for authentication. Before you begin, you'll need a free Okta developer account. Install the [Okta CLI](https://cli.okta.com) and run `okta register` to sign up for a new account. If you already have an account, run `okta login`.\n\nThen, run `okta apps create`. Select the default app name, or change it as you see fit. Choose **Web** and press **Enter**.\n\nSelect **Other**. Then, change the Redirect URI to `http://localhost:8080/authorization-code/callback` and accept the default Logout Redirect URI of `http://localhost:8080`.\n\nThe Okta CLI will create an OIDC Web App in your Okta Org. It will add the redirect URIs you specified and grant access to the Everyone group. You will see output like the following when it's finished:\n\n```\nOkta application configuration has been written to: /path/to/app/.okta.env\n```\n\nRun `cat .okta.env` (or `type .okta.env` on Windows) to see the issuer and credentials for your app.\n\n```bash\nexport OKTA_OAUTH2_ISSUER=\"https://dev-133337.okta.com/oauth2/default\"\nexport OKTA_OAUTH2_CLIENT_ID=\"0oab8eb55Kb9jdMIr5d6\"\nexport OKTA_OAUTH2_CLIENT_SECRET=\"NEVER-SHOW-SECRETS\"\n```\n\nYour Okta domain is the first part of your issuer, before `/oauth2/default`.\n\nNOTE: You can also use the Okta Admin Console to create your app. See [Create a Web App](https://developer.okta.com/docs/guides/sign-into-web-app/-/create-okta-application/) for more information.\n\nCopy your Okta values into the `.env` file to replace the `{...}` placeholders.\n\n```\nOKTA_ORG_URL=https://{yourOktaDomain}\nOKTA_CLIENT_ID={yourClientId}\nOKTA_CLIENT_SECRET={yourClientSecret}\n```\n\nNext, enable self-service registration. This will allow new users to create their own account. Run `okta login` to get the URL for your Okta org. Open the result in your favorite browser and log in to the Okta Admin Console.\n\n1. Click on the **Directory** menu and select **Self-Service Registration**.\n2. Click on the **Enable Registration** button.\n3. If you don't see this button, click **Edit** and change **Self-service registration** to *Enabled*.\n4. Click the **Save** button at the bottom of the form.\n\n### Run the Local Web Application\n\n1. Run `npm run dev` to start the development server\n1. Browse to `http://localhost:8080`\n\n### Run the Tests\n\n```bash\n\u003e npm run test\n```\n\n## Help\n\nPlease leave a commenent on this repo's [blog post](https://developer.okta.com/blog/2019/03/11/node-sql-server), [raise an issue](https://github.com/oktadeveloper/okta-node-sql-server-example/issues) if you find a problem with the example application, or visit our [Okta Developer Forums](https://devforum.okta.com/).\n\n## License\n\nApache 2.0, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fokta-node-sql-server-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktadev%2Fokta-node-sql-server-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fokta-node-sql-server-example/lists"}