Skip to content

Commit 165d1e3

Browse files
committed
Fix snapshot creation and update messages
1 parent 363e10e commit 165d1e3

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

bin/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var server = require('../src')
99

1010
updateNotifier({packageName: pkg.name, packageVersion: pkg.version}).notify()
1111

12+
// Parse arguments
1213
var argv = yargs
1314
.usage('$0 <source>')
1415
.help('help').alias('help', 'h')
@@ -26,33 +27,40 @@ var argv = yargs
2627
.require(1, 'Missing <source> argument')
2728
.argv
2829

30+
// Start server function
2931
function start(object, filename) {
3032
for (var prop in object) {
31-
console.log('http://localhost:' + port + '/' + chalk.green(prop))
33+
console.log(chalk.grey(' http://localhost:' + port + '/') + chalk.cyan(prop))
3234
}
3335

3436
console.log(
35-
'\nEnter ' + chalk.green('`s`') + ' at any time to create a snapshot of the db\n'
37+
'\nYou can now go to ' + chalk.grey('http://localhost:' + port + '/\n')
38+
)
39+
40+
console.log(
41+
'Enter ' + chalk.cyan('`s`') + ' at any time to create a snapshot of the db\n'
3642
)
3743

3844
process.stdin.resume()
3945
process.stdin.setEncoding('utf8')
4046
process.stdin.on('data', function (chunk) {
4147
if (chunk.trim().toLowerCase() === 's') {
4248
var file = 'db-' + Date.now() + '.json'
43-
_db.save(object, filename)
44-
console.log('\nSaved snapshot to ' + chalk.green(file) + '\n')
49+
_db.save(object, file)
50+
console.log('\nSaved snapshot to ' + chalk.cyan(file) + '\n')
4551
}
4652
})
4753

4854
server(object, filename).listen(port)
4955
}
5056

57+
// Set file and port
5158
var source = argv._[0]
5259
var port = process.env.PORT || argv.port
5360

54-
console.log(chalk.green('\n{^ ^} Yo!\n'))
55-
console.log('Loading database from ' + source + '\n')
61+
// Say hi, load file and start server
62+
console.log(chalk.cyan('{^_^} Hi!\n'))
63+
console.log('Loading database from ' + chalk.cyan(source))
5664

5765
if (/\.json$/.test(source)) {
5866
var filename = process.cwd() + '/' + source

src/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ <h4>Issues</h4>
5959
<hr>
6060

6161
<p>
62-
<i>To customize this page, just create a ./public/index.html file.</i>
62+
<i>To replace this page, create an index.html file in ./public, JSON Server will load it.</i>
6363
</p>
6464
</div>
6565

src/public/stylesheets/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
a {
2+
color: #1882BC !important;
3+
}
4+
15
img {
26
padding-top: 50px;
37
padding-bottom: 20px;

0 commit comments

Comments
 (0)