or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

ai-agent.mdauthentication.mdcli.mdconfiguration.mdindex.mdmiddleware.md

middleware.mddocs/

0

# Express Middleware

1

2

Parse Dashboard can be integrated as Express middleware into existing Node.js applications, providing the full dashboard functionality within your application's routing structure.

3

4

## Capabilities

5

6

### ParseDashboard Constructor

7

8

Creates Express middleware for Parse Dashboard integration.

9

10

```javascript { .api }

11

/**

12

* Creates Parse Dashboard Express middleware

13

* @param config - Dashboard configuration object

14

* @param options - Optional middleware configuration

15

* @returns Express middleware function

16

*/

17

function ParseDashboard(config: DashboardConfig, options?: MiddlewareOptions): Function;

18

19

// Alternative usage as constructor:

20

const dashboard = new ParseDashboard(config, options);

21

```

22

23

### Middleware Options

24

25

Configuration options specific to middleware integration:

26

27

```javascript { .api }

28

interface MiddlewareOptions {

29

/**

30

* Allow HTTP connections (disable HTTPS requirement)

31

* Use only behind HTTPS proxy or in development

32

*/

33

allowInsecureHTTP?: boolean;

34

35

/**

36

* Secret key for session cookie encryption

37

* Should be a long, random string

38

*/

39

cookieSessionSecret?: string;

40

41

/**

42

* Session timeout in seconds

43

* Default: session expires when browser closes

44

*/

45

cookieSessionMaxAge?: number;

46

47

/**

48

* Development mode - disables authentication

49

* DO NOT USE IN PRODUCTION

50

*/

51

dev?: boolean;

52

}

53

```

54

55

### Server Function

56

57

Standalone server creation function (used internally by CLI):

58

59

```javascript { .api }

60

/**

61

* Creates and starts standalone Parse Dashboard server

62

* @param options - Server configuration options

63

*/

64

function startServer(options: ServerOptions): void;

65

66

interface ServerOptions extends MiddlewareOptions {

67

host?: string; // Host to bind (default: 0.0.0.0)

68

port?: string; // Port to listen (default: 4040)

69

mountPath?: string; // Mount path (default: /)

70

sslKey?: string; // Path to SSL private key

71

sslCert?: string; // Path to SSL certificate

72

trustProxy?: boolean; // Trust proxy headers

73

config?: string; // Path to configuration file

74

// ... CLI options

75

}

76

```

77

78

**Usage Examples:**

79

80

```javascript

81

const express = require('express');

82

const ParseDashboard = require('parse-dashboard');

83

84

// Basic middleware integration

85

const dashboard = new ParseDashboard({

86

apps: [{

87

serverURL: 'http://localhost:1337/parse',

88

appId: 'myAppId',

89

masterKey: 'myMasterKey',

90

appName: 'My App'

91

}]

92

});

93

94

const app = express();

95

app.use('/dashboard', dashboard);

96

app.listen(4040);

97

98

// With authentication and session configuration

99

const dashboardWithAuth = new ParseDashboard({

100

apps: [{

101

serverURL: 'http://localhost:1337/parse',

102

appId: 'myAppId',

103

masterKey: 'myMasterKey',

104

appName: 'My App'

105

}],

106

users: [{

107

user: 'admin',

108

pass: 'password123'

109

}]

110

}, {

111

allowInsecureHTTP: false,

112

cookieSessionSecret: 'my-secret-key-change-this-in-production',

113

cookieSessionMaxAge: 3600000 // 1 hour

114

});

115

116

app.use('/admin/dashboard', dashboardWithAuth);

117

118

// Multiple Parse Server apps

119

const multiAppDashboard = new ParseDashboard({

120

apps: [

121

{

122

serverURL: 'http://localhost:1337/parse',

123

appId: 'app1',

124

masterKey: 'masterKey1',

125

appName: 'Production App',

126

production: true

127

},

128

{

129

serverURL: 'http://localhost:1338/parse',

130

appId: 'app2',

131

masterKey: 'masterKey2',

132

appName: 'Development App',

133

production: false

134

}

135

]

136

});

137

138

// Development mode (no authentication)

139

const devDashboard = new ParseDashboard({

140

apps: [{

141

serverURL: 'http://localhost:1337/parse',

142

appId: 'myAppId',

143

masterKey: 'myMasterKey',

144

appName: 'My App'

145

}]

146

}, {

147

dev: true,

148

allowInsecureHTTP: true

149

});

150

151

// SSL configuration (when not using reverse proxy)

152

const secureDashboard = new ParseDashboard({

153

apps: [{ /* app config */ }],

154

users: [{ /* user config */ }]

155

}, {

156

allowInsecureHTTP: false,

157

cookieSessionSecret: process.env.SESSION_SECRET

158

});

159

160

// With custom mount path and proxy settings

161

app.set('trust proxy', true);

162

app.use('/admin/parse', dashboard);

163

```

164

165

## Integration Patterns

166

167

### Reverse Proxy Setup

168

169

When running behind a reverse proxy (Nginx, Apache, etc.):

170

171

```javascript

172

const dashboard = new ParseDashboard(config, {

173

allowInsecureHTTP: true, // Proxy handles HTTPS

174

cookieSessionSecret: process.env.SESSION_SECRET

175

});

176

177

// Trust proxy headers

178

app.set('trust proxy', true);

179

app.use('/dashboard', dashboard);

180

```

181

182

### Environment-based Configuration

183

184

```javascript

185

const dashboard = new ParseDashboard({

186

apps: [{

187

serverURL: process.env.PARSE_SERVER_URL,

188

appId: process.env.PARSE_APP_ID,

189

masterKey: process.env.PARSE_MASTER_KEY,

190

appName: process.env.APP_NAME || 'My App'

191

}]

192

}, {

193

allowInsecureHTTP: process.env.NODE_ENV === 'development',

194

cookieSessionSecret: process.env.DASHBOARD_SESSION_SECRET,

195

dev: process.env.NODE_ENV === 'development'

196

});

197

```

198

199

### Multiple Applications Integration

200

201

```javascript

202

// Different dashboards for different user roles

203

const adminDashboard = new ParseDashboard(adminConfig, adminOptions);

204

const userDashboard = new ParseDashboard(userConfig, userOptions);

205

206

app.use('/admin/dashboard', adminDashboard);

207

app.use('/user/dashboard', userDashboard);

208

```

209

210

## Types

211

212

### Dashboard Configuration

213

214

```javascript { .api }

215

interface DashboardConfig {

216

apps: AppConfig[];

217

users?: UserConfig[];

218

agent?: AgentConfig;

219

useEncryptedPasswords?: boolean;

220

iconsFolder?: string;

221

trustProxy?: boolean;

222

enableResourceCache?: boolean;

223

enableSecurityChecks?: boolean;

224

}

225

```