UNPKG

6.66 kBMarkdownView Raw
1SERVER MIGRATION
2-----------------
3
4## configuration
5
6### services
7*we have broken up services a bit more, and added some new ones, what follows are key services whoes config has changed from happn2*
8
9#### database
10*the database is now versioned in the package.json, if you try and run happn-3 on an old database (mongo or nedb) startup will fail, unless you configure the data service setting autoUpdateDBVersion:true*
11```javascript
12var config = {
13 services: {
14 database:{
15 config:{
16 autoUpdateDBVersion:true
17 }
18 }
19 }
20}
21```
22#### transport service
23*of note here is how to now configure your server for https mode:*
24```javascript
25var config = {
26 services: {
27 transport:{
28 config:{
29 mode: 'https',
30 cert: '-----BEGIN CERTIFICATE-----\nMIICpDCCAYwCCQDlN4Axwf2TVzANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDEwls\nb2NhbGhvc3QwHhcNMTYwMTAzMTE1NTIyWhcNMTcwMTAyMTE1NTIyWjAUMRIwEAYD\nVQQDEwlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDc\nSceGloyefFtWgy8vC7o8w6BTaoXMc2jsvMOxT1pUHPX3jJn2bUOUC8wf3vTM8o4a\n0HY+w7cEZm/BuyTAV0dmS5SU43x9XlCF877jj5L6+ycZDncgyqW3WUWztYyqpQEz\nsMu76XvNEHW+jMMv2EGtze6k1zIcv4FiehVZR9doNOm+SilmmfVpmTmQk+E5z0Bl\n8CSnBECfvtkaYb4YqsV9dZXZcAm5xWdid7BUbqBh5w5XHz9L4aC9WiUEyMMUtwcm\n4lXDnlMkei4ixyz8oGSeOfpAP6Lp4mBjXaMFT6FalwCDAKh9rH2T3Eo9fUm18Dof\nFg4q7KcLPwd6mttP+dqvAgMBAAEwDQYJKoZIhvcNAQELBQADggEBABf8DZ+zv1P7\n8NnDZzuhif+4PveSfAMQrGR+4BS+0eisciif1idyjlxsPF28i82eJOBya4xotRlW\netAqSIjw8Osqxy4boQw3aa+RBtEAZR6Y/h3dvb8eI/jmFqJzmFjdGZzEMO7YlE1B\nxZIbA86dGled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HDqkWzgbo6EbjjFro\nAyyHHtYRxo/f1TWWs6RpNjJ3hDCc3OpghkwkZkN9v9wd4RMCW2kdA2MCgYEA3l20\nhxpSTJffbKKQTAxURW9v+YUxNQFb74892AMlCnMiCppvS0it8wt0gJwnlNPV92no\nUVLZ+gVXdo8E+kKca4GW/TDgceDPqw2EbkTF1ZCxxy/kwgPWR471ku3Zyg6xel3Z\nMU67EriKz1zJaMjm7JmSjoz3+u8PbLYIf+fpm0UCgYAnkU0GtzGA9lXjpOX5oy2C\ngB7vKGd41u2TtTmctS/eB51bYPzZCcyfs9E6H2BNVS0SyBYFkCKVpsBavK4t4p4f\nOKI1eDFDWcKIDt4KwoTlVhymiNDdyB0kyaC3Rez2DuJ8UGUX2BH2O797513B9etj\naKPRNLx836nlwOKAQpEdQwKBgQCvV7io6CqJVyDI6w9ZyEcTUaI8YbjBkUbLimo7\n0Y79xHfNYKXt+WuhQSEm4PudMcWBCTQ2HFzh+CBVzsUgCjKJ23ASSt5RLfLTcR9C\nTFyr4SMubCe4jYoEd0hSCdg4qolscmB3rxt40agzh3kSdYkSfK7CVYqdhrDlCk19\nfoQI+QKBgQD9PIEvhEnQO0R1k3EzchRo67IkWLyR4uX4hXa7IOXppde9dAwhbZqP\nUkw8tqj7Cg02hfXq+KdRn+xfh6pc708RMqqdqNqSfL2PYedAR65hDKV4rL8PVmL9\n0P4j3FT1nwa/sHW5jLuO5TcevPrlhEQ9xVbKw7I7IJivKMamukskUA==\n-----END RSA PRIVATE KEY-----'
32 }
33 }
34 }
35}
36```
37
38####protocol service
39*the protocol service is what controls the http/s server, this is where you can inject inbound and outbound message handlers:*
40```javascript
41var inboundLayers = [
42 function(message, cb){
43 layerLog3.push(message);
44 return cb(null, message);
45 },
46 function(message, cb){
47 layerLog4.push(message);
48 return cb(null, message);
49 }
50];
51
52var outboundLayers = [
53 function(message, cb){
54 layerLog1.push(message);
55 return cb(null, message);
56 },
57 function(message, cb){
58 layerLog2.push(message);
59 return cb(null, message);
60 }
61];
62
63var serviceConfig = {
64 secure: true,
65 services:{
66 protocol:{
67 config:{
68 outboundLayers:outboundLayers,
69 inboundLayers:inboundLayers
70 }
71 }
72 }
73};
74```
75
76####security service
77*the security service, and its attendant utility helpers, users and checkpoint, manages users and groups, and via the checkpoint performs authentication and authorization functions, user and group management has changed as we now have a users helper*
78
79```
80
81//old happn
82myInstance.services.security.upsertUser(...
83myInstance.services.security.upsertGroup(...
84myInstance.services.security.listGroups...
85myInstance.services.security.liunkGroup...
86
87//new happn
88myInstance.services.security.users.upsertUser(...
89myInstance.services.security.users.upsertGroup(...
90myInstance.services.security.users.listGroups...
91myInstance.services.security.users.liunkGroup...
92
93```
94
95####session service
96*the session service controls primus, and also manages client sessions*
97
98
99
100####pubsub service
101*in happn v2, this service what effectively doing everything from managing sessions to starting up the http/s server and finally what it was meant to, manage subsriptions, now all it does is manage subscriptions*
102
103
104CLIENT MIGRATION:
105-----------------
106
107##configuration
108
109###no more config.config
110*the client config is simpler, just key value pairs, instead of a .config branch, this is backwards compatible still, but it is recommended to change your configs if possible*
111
112```javascript
113
114//OLD
115var clientConfig = {config:{username:'simon', port:10000}}
116//
117//
118//NEW
119var clientConfig = {username:'simon', port:10000}
120
121```
122
123##intra-proc client
124*the intra-proc client is now instantiated via the session service:*
125
126```javascript
127
128
129//OLD
130 happn_client.create({
131 plugin: happn.client_plugins.intra_process,
132 context: happnInstance
133 }, function (e, instance) { ...
134//
135//
136//NEW
137 happnInstance.services.session.localClient(function(e, instance){...
138
139```
140##protocol changes:
141*the happn protocol has changed in 3 places:*
142
143###disconnect message form server:
144*the server will warn all clients that they are about to be diconnected from the server side:*
145```javascript
146
147```
148
149###disconnect message from client:
150*to disconnect the client form the server properly, post a disconnect message*
151```javascript
152
153```
154
155###error message
156
157```javascript
158OLD: {error:{name:'AccessDenied: unauthorized'}}
159
160NEW: {error:{name:'AccessDenied', message:'unauthorized'}}
161
162```