FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
androidstarters.com/app.js at develop · androidstarters/androidstarters.com · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
androidstarters
/
androidstarters.com
Public
Notifications
You must be signed in to change notification settings
Fork
26
Star
291
Code
Issues
9
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
androidstarters.com
/
app.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
104 lines (91 loc) · 2.45 KB
Breadcrumbs
androidstarters.com
/
app.js
Copy path
File metadata and controls
104 lines (91 loc) · 2.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* Module dependencies.
*/
const
express
=
require
(
'express'
)
;
const
bodyParser
=
require
(
'body-parser'
)
;
const
logger
=
require
(
'morgan'
)
;
const
chalk
=
require
(
'chalk'
)
;
const
dotenv
=
require
(
'dotenv'
)
;
const
sass
=
require
(
'node-sass-middleware'
)
;
const
path
=
require
(
'path'
)
;
const
androidstarters
=
require
(
'androidstarters'
)
;
const
merge
=
require
(
'lodash.merge'
)
;
const
rimraf
=
require
(
'rimraf'
)
;
const
Mixpanel
=
require
(
'mixpanel'
)
;
/**
* Load environment variables from .env file, where API keys and passwords are configured.
*/
dotenv
.
load
(
{
path
:
'.env.example'
}
)
;
/**
* Controllers (route handlers).
*/
const
mixpanel
=
Mixpanel
.
init
(
process
.
env
.
MIXPANEL_API_KEY
)
;
/**
* Create Express server.
*/
const
app
=
express
(
)
;
/**
* Express configuration.
*/
app
.
set
(
'port'
,
process
.
env
.
PORT
||
3000
)
;
app
.
set
(
'views'
,
path
.
join
(
__dirname
,
'views'
)
)
;
app
.
set
(
'view engine'
,
'pug'
)
;
app
.
use
(
sass
(
{
src
:
path
.
join
(
__dirname
,
'public'
)
,
dest
:
path
.
join
(
__dirname
,
'public'
)
}
)
)
;
app
.
use
(
logger
(
'dev'
)
)
;
app
.
use
(
bodyParser
.
json
(
)
)
;
app
.
use
(
bodyParser
.
urlencoded
(
{
extended
:
true
}
)
)
;
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'public'
)
,
{
maxAge
:
31557600000
}
)
)
;
/**
* Primary app routes.
*/
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
res
.
render
(
'home'
,
{
title
:
'Home'
}
)
;
}
)
;
app
.
post
(
'/download'
,
(
req
,
res
)
=>
{
var
config
=
{
appName
:
req
.
body
.
appName
,
packageName
:
req
.
body
.
packageName
,
templateName
:
req
.
body
.
templateName
,
props
:
{
appPackage
:
req
.
body
.
packageName
}
}
;
mixpanel
.
track
(
'Download'
,
config
)
;
if
(
config
.
templateName
.
length
===
0
)
config
.
templatename
=
'androidstarters-java'
;
const
templateConfig
=
require
(
'./config/'
+
config
.
templateName
+
'.json'
)
;
config
.
packageDir
=
config
.
packageName
.
replace
(
/
\.
/
g
,
'/'
)
;
config
.
templatePath
=
process
.
env
.
PWD
+
'/templates/'
+
config
.
templateName
+
'/'
;
config
=
merge
(
config
,
templateConfig
)
;
config
.
appPath
=
path
.
join
(
__dirname
,
config
.
appName
+
'/'
)
;
androidstarters
(
config
,
function
(
filePath
)
{
var
file
=
path
.
join
(
__dirname
,
filePath
)
;
res
.
download
(
file
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
"Error"
)
;
console
.
log
(
err
)
;
}
else
{
console
.
log
(
"Success"
)
;
rimraf
.
sync
(
file
)
;
}
}
)
;
}
)
;
}
)
;
/**
* Start Express server.
*/
app
.
listen
(
app
.
get
(
'port'
)
,
(
)
=>
{
console
.
log
(
'%s App is running at http://localhost:%d in %s mode'
,
chalk
.
green
(
'✓'
)
,
app
.
get
(
'port'
)
,
app
.
get
(
'env'
)
)
;
console
.
log
(
' Press CTRL-C to stop\n'
)
;
}
)
;
module
.
exports
=
app
;
Back
|
FazBrowse Home
|
New Git URL