Skip to content
This repository was archived by the owner on Aug 18, 2023. It is now read-only.

Commit 40838db

Browse files
committed
Initial commit
0 parents  commit 40838db

26 files changed

+525
-0
lines changed

Diff for: .editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# http://editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
indent_style = space
9+
indent_size = 2
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/client/

Diff for: .eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "loopback"
3+
}

Diff for: .gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*.csv
2+
*.dat
3+
*.iml
4+
*.log
5+
*.out
6+
*.pid
7+
*.seed
8+
*.sublime-*
9+
*.swo
10+
*.swp
11+
*.tgz
12+
*.xml
13+
.DS_Store
14+
.idea
15+
.project
16+
.strong-pm
17+
coverage
18+
node_modules
19+
npm-debug.log

Diff for: .yo-rc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"generator-loopback": {}
3+
}

Diff for: README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
**PLEASE CREATE ISSUES AT https://github.com/strongloop/loopback/issues**
2+
3+
---
4+
5+
#loopback-getting-started
6+
7+
This is the example application that accompanies the [Getting started with LoopBack](http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack) tutorial. Follow the steps in the tutorial to create this application from scratch.
8+
9+
NOTE: This repository has commits for each step of the tutorial, so you can pick up the tutorial at any point along the way:
10+
11+
See [Getting started with LoopBack](http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack) for step-by-step instructions to create this application.
12+
13+
---
14+
15+
[More LoopBack examples](https://github.com/strongloop/loopback-example)

Diff for: bin/arcdemo.mysqldump.sql

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- MySQL dump 10.13 Distrib 5.6.20, for osx10.8 (x86_64)
2+
--
3+
-- Host: localhost Database: getting_started
4+
-- ------------------------------------------------------
5+
-- Server version 5.6.20
6+
7+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10+
/*!40101 SET NAMES utf8 */;
11+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12+
/*!40103 SET TIME_ZONE='+00:00' */;
13+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17+
18+
--
19+
-- Table structure for table `CoffeeShop`
20+
--
21+
22+
DROP TABLE IF EXISTS `CoffeeShop`;
23+
/*!40101 SET @saved_cs_client = @@character_set_client */;
24+
/*!40101 SET character_set_client = utf8 */;
25+
CREATE TABLE `CoffeeShop` (
26+
`id` int(11) NOT NULL AUTO_INCREMENT,
27+
`name` varchar(512) DEFAULT NULL,
28+
`city` varchar(512) DEFAULT NULL,
29+
PRIMARY KEY (`id`)
30+
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
31+
/*!40101 SET character_set_client = @saved_cs_client */;
32+
33+
--
34+
-- Dumping data for table `CoffeeShop`
35+
--
36+
37+
LOCK TABLES `CoffeeShop` WRITE;
38+
/*!40000 ALTER TABLE `CoffeeShop` DISABLE KEYS */;
39+
INSERT INTO `CoffeeShop` VALUES (1,'Bel Cafe','Vancouver'),(2,'Three Bees Coffee House','San Mateo'),(3,'Caffe Artigiano','Vancouver');
40+
/*!40000 ALTER TABLE `CoffeeShop` ENABLE KEYS */;
41+
UNLOCK TABLES;
42+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43+
44+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
45+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
46+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
47+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
48+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
49+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
50+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
51+
52+
-- Dump completed on 2014-12-03 13:55:19

Diff for: bin/arcdemo.sql

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- MySQL dump 10.13 Distrib 5.6.20, for osx10.8 (x86_64)
2+
--
3+
-- Host: localhost Database: getting_started
4+
-- ------------------------------------------------------
5+
-- Server version 5.6.20
6+
7+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10+
/*!40101 SET NAMES utf8 */;
11+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12+
/*!40103 SET TIME_ZONE='+00:00' */;
13+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17+
18+
--
19+
-- Table structure for table `CoffeeShop`
20+
--
21+
22+
DROP TABLE IF EXISTS `CoffeeShop`;
23+
/*!40101 SET @saved_cs_client = @@character_set_client */;
24+
/*!40101 SET character_set_client = utf8 */;
25+
CREATE TABLE `CoffeeShop` (
26+
`id` int(11) NOT NULL AUTO_INCREMENT,
27+
`name` varchar(512) DEFAULT NULL,
28+
`city` varchar(512) DEFAULT NULL,
29+
PRIMARY KEY (`id`)
30+
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
31+
/*!40101 SET character_set_client = @saved_cs_client */;
32+
33+
--
34+
-- Dumping data for table `CoffeeShop`
35+
--
36+
37+
LOCK TABLES `CoffeeShop` WRITE;
38+
/*!40000 ALTER TABLE `CoffeeShop` DISABLE KEYS */;
39+
INSERT INTO `CoffeeShop` VALUES (1,'Bel Cafe','Vancouver'),(2,'Three Bees Coffee House','San Mateo'),(3,'Caffe Artigiano','Vancouver');
40+
/*!40000 ALTER TABLE `CoffeeShop` ENABLE KEYS */;
41+
UNLOCK TABLES;
42+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43+
44+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
45+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
46+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
47+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
48+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
49+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
50+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
51+
52+
-- Dump completed on 2014-12-03 13:55:19

Diff for: bin/demo.mysqldump.sql

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- MySQL dump 10.13 Distrib 5.6.20, for osx10.8 (x86_64)
2+
--
3+
-- Host: localhost Database: getting_started
4+
-- ------------------------------------------------------
5+
-- Server version 5.6.20
6+
7+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10+
/*!40101 SET NAMES utf8 */;
11+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12+
/*!40103 SET TIME_ZONE='+00:00' */;
13+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17+
18+
--
19+
-- Table structure for table `CoffeeShop`
20+
--
21+
22+
DROP TABLE IF EXISTS `CoffeeShop`;
23+
/*!40101 SET @saved_cs_client = @@character_set_client */;
24+
/*!40101 SET character_set_client = utf8 */;
25+
CREATE TABLE `CoffeeShop` (
26+
`id` int(11) NOT NULL AUTO_INCREMENT,
27+
`name` varchar(512) DEFAULT NULL,
28+
`city` varchar(512) DEFAULT NULL,
29+
PRIMARY KEY (`id`)
30+
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
31+
/*!40101 SET character_set_client = @saved_cs_client */;
32+
33+
--
34+
-- Dumping data for table `CoffeeShop`
35+
--
36+
37+
LOCK TABLES `CoffeeShop` WRITE;
38+
/*!40000 ALTER TABLE `CoffeeShop` DISABLE KEYS */;
39+
INSERT INTO `CoffeeShop` VALUES (1,'Bel Cafe','Vancouver'),(2,'Three Bees Coffee House','San Mateo'),(3,'Caffe Artigiano','Vancouver');
40+
/*!40000 ALTER TABLE `CoffeeShop` ENABLE KEYS */;
41+
UNLOCK TABLES;
42+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
43+
44+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
45+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
46+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
47+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
48+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
49+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
50+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
51+
52+
-- Dump completed on 2014-12-03 13:55:19

Diff for: bin/demo.sql

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Drop `CoffeeShop` table if it exists
2+
DROP TABLE IF EXISTS `CoffeeShop`;
3+
4+
-- Create a new `CoffeeShop` table
5+
CREATE TABLE `CoffeeShop` (
6+
`id` int(11) NOT NULL AUTO_INCREMENT,
7+
`name` varchar(512) DEFAULT NULL,
8+
`city` varchar(512) DEFAULT NULL,
9+
PRIMARY KEY (`id`)
10+
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
11+
12+
-- Insert values into the new `CoffeeShop` table
13+
INSERT INTO `CoffeeShop` VALUES (1,'Bel Cafe','Vancouver'),(2,'Three Bees Coffee House','San Mateo'),(3,'Caffe Artigiano','Vancouver');

Diff for: client/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Client
2+
3+
This is the place for your application front-end files.

Diff for: client/index.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<head><title>LoopBack</title></head>
2+
<body>
3+
<h1>LoopBack Rocks!</h1>
4+
<p>Hello World... </p>
5+
</body>

Diff for: common/models/coffee-shop.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
module.exports = function(CoffeeShop) {
4+
CoffeeShop.status = function(cb) {
5+
var currentDate = new Date();
6+
var currentHour = currentDate.getHours();
7+
var OPEN_HOUR = 6;
8+
var CLOSE_HOUR = 20;
9+
console.log('Current hour is ' + currentHour);
10+
var response;
11+
if (currentHour > OPEN_HOUR && currentHour < CLOSE_HOUR) {
12+
response = 'We are open for business.';
13+
} else {
14+
response = 'Sorry, we are closed. Open daily from 6am to 8pm.';
15+
}
16+
cb(null, response);
17+
};
18+
CoffeeShop.remoteMethod(
19+
'status',
20+
{
21+
http: {path: '/status', verb: 'get'},
22+
returns: {arg: 'status', type: 'string'},
23+
}
24+
);
25+
};

Diff for: common/models/coffee-shop.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "CoffeeShop",
3+
"base": "PersistedModel",
4+
"idInjection": true,
5+
"options": {
6+
"validateUpsert": true
7+
},
8+
"properties": {
9+
"name": {
10+
"type": "string",
11+
"required": true
12+
},
13+
"city": {
14+
"type": "string",
15+
"required": true
16+
}
17+
},
18+
"validations": [],
19+
"relations": {},
20+
"acls": [],
21+
"methods": {}
22+
}

Diff for: package.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "loopback-getting-started",
3+
"version": "1.0.0",
4+
"main": "server/server.js",
5+
"scripts": {
6+
"lint": "eslint .",
7+
"start": "node .",
8+
"posttest": "npm run lint && nsp check"
9+
},
10+
"dependencies": {
11+
"compression": "^1.0.3",
12+
"cors": "^2.5.2",
13+
"helmet": "^1.3.0",
14+
"loopback": "^2.22.0",
15+
"loopback-boot": "^2.6.5",
16+
"loopback-component-explorer": "^2.4.0",
17+
"loopback-connector-mysql": "^2.3.0",
18+
"loopback-datasource-juggler": "^2.39.0",
19+
"serve-favicon": "^2.0.1",
20+
"strong-error-handler": "^1.0.1"
21+
},
22+
"devDependencies": {
23+
"eslint": "^2.13.1",
24+
"eslint-config-loopback": "^4.0.0",
25+
"nsp": "^2.1.0"
26+
},
27+
"repository": {
28+
"type": "",
29+
"url": ""
30+
},
31+
"license": "UNLICENSED",
32+
"description": "loopback-getting-started"
33+
}

Diff for: server/boot/authentication.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
module.exports = function enableAuthentication(server) {
4+
// enable authentication
5+
server.enableAuth();
6+
};

Diff for: server/boot/create-sample-models.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
module.exports = function(app) {
4+
app.dataSources.mysqlDs.automigrate('CoffeeShop', function(err) {
5+
if (err) throw err;
6+
7+
app.models.CoffeeShop.create([
8+
{name: 'Bel Cafe', city: 'Vancouver'},
9+
{name: 'Three Bees Coffee House', city: 'San Mateo'},
10+
{name: 'Caffe Artigiano', city: 'Vancouver'},
11+
], function(err, coffeeShops) {
12+
if (err) throw err;
13+
14+
console.log('Models created: \n', coffeeShops);
15+
});
16+
});
17+
};

Diff for: server/boot/root.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
module.exports = function(server) { // Install a `/` route that returns server status
4+
var router = server.loopback.Router();
5+
router.get('/', server.loopback.status());
6+
server.use(router);
7+
};

Diff for: server/boot/routes.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
module.exports = function(app) {
4+
// Install a "/ping" route that returns "pong"
5+
app.get('/ping', function(req, res) {
6+
res.send('pong');
7+
});
8+
};

Diff for: server/component-config.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"loopback-component-explorer": {
3+
"mountPath": "/explorer"
4+
}
5+
}

0 commit comments

Comments
 (0)