File tree Expand file tree Collapse file tree 3 files changed +23
-21
lines changed
Expand file tree Collapse file tree 3 files changed +23
-21
lines changed Original file line number Diff line number Diff line change 11const Router = require ( 'router' )
22const qs = require ( 'querystring' )
33const cors = require ( 'cors' )
4+ const landingTemplate = require ( './landingTemplate' )
45
56const warned = { }
67
@@ -33,8 +34,28 @@ function getRouter({ manifest , get }) {
3334 console . warn ( 'manifest.config is set but manifest.behaviorHints.configurable is disabled, the "Configure" button will not show in the Stremio apps' )
3435 }
3536
37+ // landing page
38+ const landingHTML = landingTemplate ( manifest )
39+
40+ router . get ( '/' , ( _ , res ) => {
41+ if ( hasConfig ) {
42+ res . redirect ( '/configure' )
43+ } else {
44+ res . setHeader ( 'content-type' , 'text/html' )
45+ res . end ( landingHTML )
46+ }
47+ } )
48+
49+ if ( hasConfig ) {
50+ router . get ( '/configure' , ( _ , res ) => {
51+ res . setHeader ( 'content-type' , 'text/html' )
52+ res . end ( landingHTML )
53+ } )
54+ }
55+
56+
3657 const configPrefix = hasConfig ? '/:config?' : ''
37- // having config prifix always set to '/:config?' won't resault in a problem for non configurable addons,
58+ // having config prefix always set to '/:config?' won't result in a problem for non- configurable addons,
3859 // since now the order is restricted by resources.
3960
4061 router . get ( `${ configPrefix } /manifest.json` , manifestHandler )
Original file line number Diff line number Diff line change @@ -2,5 +2,6 @@ module.exports = {
22 addonBuilder : require ( './builder' ) ,
33 serveHTTP : require ( './serveHTTP' ) ,
44 getRouter : require ( './getRouter' ) ,
5+ landingTemplate : require ( './landingTemplate' ) ,
56 publishToCentral : require ( './publishToCentral' ) ,
67}
Original file line number Diff line number Diff line change 11const express = require ( 'express' )
22const fs = require ( 'fs' )
33const path = require ( 'path' )
4- const landingTemplate = require ( './landingTemplate' )
54const getRouter = require ( './getRouter' )
65const opn = require ( 'opn' )
76
@@ -30,25 +29,6 @@ function serveHTTP(addonInterface, opts = {}) {
3029 app . use ( opts . static , express . static ( location ) )
3130 }
3231
33- const hasConfig = ! ! ( addonInterface . manifest . config || [ ] ) . length
34-
35- // landing page
36- const landingHTML = landingTemplate ( addonInterface . manifest )
37- app . get ( '/' , ( _ , res ) => {
38- if ( hasConfig ) {
39- res . redirect ( '/configure' )
40- } else {
41- res . setHeader ( 'content-type' , 'text/html' )
42- res . end ( landingHTML )
43- }
44- } )
45-
46- if ( hasConfig )
47- app . get ( '/configure' , ( _ , res ) => {
48- res . setHeader ( 'content-type' , 'text/html' )
49- res . end ( landingHTML )
50- } )
51-
5232 const server = app . listen ( opts . port )
5333 return new Promise ( function ( resolve , reject ) {
5434 server . on ( 'listening' , function ( ) {
You can’t perform that action at this time.
0 commit comments