Skip to content

Commit 937951f

Browse files
committed
Updated todo app readme.md file
1 parent bb95b8b commit 937951f

File tree

1 file changed

+21
-19
lines changed
  • samples/features/json/todo-app/nodejs-express4-rest-api

1 file changed

+21
-19
lines changed

samples/features/json/todo-app/nodejs-express4-rest-api/README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This project contains an example implementation of NodeJS REST API with CRUD ope
1717

1818
- **Applies to:** SQL Server 2016 (or higher), Azure SQL Database
1919
- **Key features:** JSON Functions in SQL Server 2016/Azure SQL Database - FOR JSON and OPENJSON
20-
- **Programming Language:** JavaScript (NodeJS)
20+
- **Programming Language:** JavaScript (NodeJS), T-SQL
2121
- **Authors:** Jovan Popovic
2222

2323
<a name=before-you-begin></a>
@@ -31,7 +31,6 @@ To run this sample, you need the following prerequisites.
3131
1. SQL Server 2016 (or higher) or an Azure SQL Database
3232
2. Node.js runtime.
3333

34-
3534
**Azure prerequisites:**
3635

3736
1. Permission to create an Azure SQL Database
@@ -40,26 +39,30 @@ To run this sample, you need the following prerequisites.
4039

4140
## Run this sample
4241

43-
1. Navigate to the folder where you have downloaded sample and run **npm install** in command window.
42+
1. Navigate to the folder where you have downloaded sample and run **npm update** in the command window.
4443

4544
2. From SQL Server Management Studio or SQL Server Data Tools connect to your SQL Server 2016 or Azure SQL database and
46-
execute setup.sql script that will create and populate Todo table in the database.
47-
48-
3. Locate db.js file in the project, change database connection info in createConnection() method to reference your database. the following tokens should be replaced:
49-
1. SERVERNAME - name of the database server.
50-
2. DATABASE - Name of database where Todo table is stored.
51-
3. USERNAME - SQL Server login that can access table data and execute stored procedures.
52-
4. PASSWORD - Password associated to SQL Server login.
45+
execute setup.sql script that will create and populate Todo table in the database and create necessary stored procedures.
5346

47+
3. Locate config folder in the project and setup connection info in default.json file. The content of the file should look like:
5448
```
55-
var config = {
56-
server : "SERVER.database.windows.net",
57-
userName: "USER",
58-
password: "PASSWORD",
59-
// If you're on Azure, you will need this:
60-
options: { encrypt: true, database: 'DATABASE' }
61-
};
49+
{
50+
"connection":{
51+
"server" : "<<server name or ip>>",
52+
"userName": "<<user name>>",
53+
"password": "<<password>>",
54+
"options": { "encrypt": true, "database": "<<database name>>" }
55+
}
56+
}
6257
```
58+
Content under connection key will be passed to Tedious package, which is used to
59+
interact with SQL Database. You can find more information
60+
about the properties in this object on [Tedious site](http://tediousjs.github.io/tedious/getting-started.html).
61+
62+
As an alternative, you can put connection info into Development.json or
63+
Production.json file. This sample uses [config](https://www.npmjs.com/package/config)
64+
npm module to read configurations from a file, so you can find more information about
65+
the configuration there.
6366

6467
4. Run sample app from the command line using **node app.js**
6568
1. Open http://localhost:3000/todo Url to get list of all Todo items from a table,
@@ -73,8 +76,7 @@ execute setup.sql script that will create and populate Todo table in the databas
7376
This sample application shows how to create simple REST API service that performs CRUD operations on a simple Todo table.
7477
NodeJS REST API is used to implement REST Service in the example.
7578
1. app.js file that contains startup code.
76-
2. db.js file that contains functions that wrap Tedious library
77-
3. todo.js file that contains action that will be called on GET, POST, PUT, and DELETE Http requests.
79+
3. routes/todo.js file that contains action that will be called on GET, POST, PUT, and DELETE Http requests.
7880

7981
Service uses Tedious library for data access and built-in JSON functionalities that are available in SQL Server 2016 and Azure SQL Database.
8082

0 commit comments

Comments
 (0)